Class: Appilf::ResourcePage
- Inherits:
-
AppilfObject
- Object
- AppilfObject
- Appilf::ResourcePage
- Includes:
- APIActions, Enumerable
- Defined in:
- lib/appilf/resource_page.rb
Constant Summary
Constants included from APIActions
Instance Attribute Summary collapse
-
#items ⇒ Object
Returns the value of attribute items.
-
#page_links ⇒ Object
:prev, :next.
-
#page_meta ⇒ Object
:page_number , :page_size, :total_results.
Attributes inherited from AppilfObject
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(paginated_response) ⇒ ResourcePage
constructor
A new instance of ResourcePage.
- #next ⇒ Object
- #previous ⇒ Object
Methods included from APIActions
#api_delete, #api_get, #api_post, #handle_from_response
Methods inherited from AppilfObject
#add_relationships, #init_meta_data, #method_missing, #respond_to_missing?
Constructor Details
#initialize(paginated_response) ⇒ ResourcePage
Returns a new instance of ResourcePage.
33 34 35 36 37 38 |
# File 'lib/appilf/resource_page.rb', line 33 def initialize(paginated_response) (paginated_response) paginated_response['data'].each do |api_element_data_hash| self.items << Util.translate_from_response({'data' => api_element_data_hash}) end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Appilf::AppilfObject
Instance Attribute Details
#items ⇒ Object
Returns the value of attribute items.
7 8 9 |
# File 'lib/appilf/resource_page.rb', line 7 def items @items end |
#page_links ⇒ Object
:prev, :next
17 18 19 |
# File 'lib/appilf/resource_page.rb', line 17 def page_links @page_links end |
#page_meta ⇒ Object
:page_number , :page_size, :total_results
12 13 14 |
# File 'lib/appilf/resource_page.rb', line 12 def @page_meta end |
Instance Method Details
#each(&block) ⇒ Object
40 41 42 |
# File 'lib/appilf/resource_page.rb', line 40 def each(&block) self.items.each(&block) end |
#next ⇒ Object
21 22 23 |
# File 'lib/appilf/resource_page.rb', line 21 def next get_page(page_links.next) end |
#previous ⇒ Object
25 26 27 |
# File 'lib/appilf/resource_page.rb', line 25 def previous get_page(page_links.prev) end |