Class: SweeperAPI::Resources::Response

Inherits:
Base
  • Object
show all
Defined in:
lib/sweeper_api/resources/response.rb

Instance Method Summary collapse

Methods inherited from Base

dynamic_accessor

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



2
3
4
5
6
7
# File 'lib/sweeper_api/resources/response.rb', line 2

def initialize(response)
  paginated         = response["data"].is_a?(Array)
  response["links"] = parse_links(response.delete("links"), paginated: paginated)

  super(response)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object (private)



15
16
17
18
# File 'lib/sweeper_api/resources/response.rb', line 15

def method_missing(method, *args)
  return data.public_send(method, *args) if data_method?(method)
  super
end

Instance Method Details

#paged_response?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/sweeper_api/resources/response.rb', line 9

def paged_response?
  data.is_a?(Array)
end