class ContentNetwork::Collection

Public Class Methods

new(response) click to toggle source
# File lib/content_network/collection.rb, line 3
def initialize(response)
  @response = response
end

Public Instance Methods

data() click to toggle source
# File lib/content_network/collection.rb, line 7
def data
  return nil if error?
  parsed_response['data']
end
error() click to toggle source
# File lib/content_network/collection.rb, line 27
def error
  parsed_response
  @error
end
error?() click to toggle source
# File lib/content_network/collection.rb, line 22
def error?
  parsed_response
  @error.present?
end
pagination() click to toggle source
# File lib/content_network/collection.rb, line 17
def pagination
  return nil unless pagination?
  parsed_response['meta']['pagination']
end
pagination?() click to toggle source
# File lib/content_network/collection.rb, line 12
def pagination?
  return false if error?
  parsed_response['meta'].has_key?('pagination')
end

Private Instance Methods

parsed_response() click to toggle source
# File lib/content_network/collection.rb, line 34
def parsed_response
  @parsed_response ||= JSON.parse(@response)
rescue JSON::ParserError => e
  @error = e.message
end