Class: UserManagementApi::PagedCollection
- Inherits:
-
Object
- Object
- UserManagementApi::PagedCollection
- Extended by:
- Forwardable
- Defined in:
- lib/user_management_api/paged_collection.rb
Instance Attribute Summary collapse
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
-
#current_page ⇒ Object
readonly
Returns the value of attribute current_page.
-
#total_count ⇒ Object
readonly
Returns the value of attribute total_count.
-
#total_pages ⇒ Object
readonly
Returns the value of attribute total_pages.
Instance Method Summary collapse
-
#initialize(entity_type, collection_name, data) ⇒ PagedCollection
constructor
A new instance of PagedCollection.
Constructor Details
#initialize(entity_type, collection_name, data) ⇒ PagedCollection
Returns a new instance of PagedCollection.
9 10 11 12 13 14 |
# File 'lib/user_management_api/paged_collection.rb', line 9 def initialize(entity_type, collection_name, data) @total_count = data['total_count'] @total_pages = data['total_pages'] @current_page = data['current_page'] @collection = (data[collection_name.to_s] || []).map { |e| entity_type.new(e) } end |
Instance Attribute Details
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
7 8 9 |
# File 'lib/user_management_api/paged_collection.rb', line 7 def collection @collection end |
#current_page ⇒ Object (readonly)
Returns the value of attribute current_page.
7 8 9 |
# File 'lib/user_management_api/paged_collection.rb', line 7 def current_page @current_page end |
#total_count ⇒ Object (readonly)
Returns the value of attribute total_count.
7 8 9 |
# File 'lib/user_management_api/paged_collection.rb', line 7 def total_count @total_count end |
#total_pages ⇒ Object (readonly)
Returns the value of attribute total_pages.
7 8 9 |
# File 'lib/user_management_api/paged_collection.rb', line 7 def total_pages @total_pages end |