Class: Episodic::Platform::CollectionResponse
- Defined in:
- lib/episodic/platform/collection_response.rb
Overview
Base class for responses that return an collection of objects.
Direct Known Subclasses
Constant Summary collapse
- COLLECTION_RESPONSE_ATTRIBUTES =
[:page, :pages, :total, :per_page]
Instance Method Summary collapse
-
#initialize(response, xml_options = {}) ⇒ CollectionResponse
constructor
Constructor.
-
#method_missing(method_sym, *arguments, &block) ⇒ Object
Override to look up attributes by name.
-
#respond_to?(symbol, include_private = false) ⇒ Boolean
Attributes can be accessed as methods.
Methods inherited from Response
Constructor Details
#initialize(response, xml_options = {}) ⇒ CollectionResponse
Constructor
Parameters
- response<Episodic::Platform::HttpResponse>
-
The response object returned from an Episodic Platform API request.
- xml_options<Hash>
-
A set of options used by XmlSimple when parsing the response body
20 21 22 |
# File 'lib/episodic/platform/collection_response.rb', line 20 def initialize response, = {} super(response, ) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_sym, *arguments, &block) ⇒ Object
Override to look up attributes by name
27 28 29 30 31 32 33 34 |
# File 'lib/episodic/platform/collection_response.rb', line 27 def method_missing(method_sym, *arguments, &block) method_name = method_sym.to_s if (COLLECTION_RESPONSE_ATTRIBUTES.include?(method_sym)) return @parsed_body[method_name].to_i end return super end |
Instance Method Details
#respond_to?(symbol, include_private = false) ⇒ Boolean
Attributes can be accessed as methods.
39 40 41 |
# File 'lib/episodic/platform/collection_response.rb', line 39 def respond_to?(symbol, include_private = false) return COLLECTION_RESPONSE_ATTRIBUTES.include?(symbol) end |