class Azure::Armrest::ArmrestCollection

Attributes

continuation_token[RW]
response_code[RW]
response_headers[RW]
skip_token[RW]
skip_token=[RW]

Public Class Methods

create_from_response(response, klass = nil, skip_accessors_definition = false) click to toggle source

Creates and returns a ArmrestCollection object based on JSON input, using klass to generate the list elements. In addition, both the response headers and continuation token are set.

# File lib/azure/armrest/armrest_collection.rb, line 19
def create_from_response(response, klass = nil, skip_accessors_definition = false)
  json_response = JSON.parse(response)
  array = new(json_response['value'].map { |hash| klass.new(hash, skip_accessors_definition) })

  array.response_code = response.code
  array.response_headers = response.headers
  array.next_link = json_response['nextLink']
  array.continuation_token = parse_skip_token(array.next_link)

  array
end

Private Class Methods

parse_skip_token(next_link) click to toggle source

Parse the skip token value out of the nextLink attribute from a response.

# File lib/azure/armrest/armrest_collection.rb, line 34
def parse_skip_token(next_link)
  return nil unless next_link
  next_link[/.*?skipToken=(.*?)$/i, 1]
end