Class: UserManagementApi::PagedCollection

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/user_management_api/paged_collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#collectionObject (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_pageObject (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_countObject (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_pagesObject (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