Class: PaginatedCollection::Base
- Inherits:
-
Array
- Object
- Array
- PaginatedCollection::Base
- Defined in:
- lib/paginated_collection/base.rb
Instance Attribute Summary collapse
-
#pagination ⇒ Object
Returns the value of attribute pagination.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*members, pagination: {}) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(*members, pagination: {}) ⇒ Base
Returns a new instance of Base.
6 7 8 9 10 11 12 13 14 |
# File 'lib/paginated_collection/base.rb', line 6 def initialize *members, pagination: {} p = pagination.symbolize_keys @pagination = Pagination.new(p[:current_page], p[:total_pages], p[:per_page], p[:total]) super members end |
Instance Attribute Details
#pagination ⇒ Object
Returns the value of attribute pagination.
4 5 6 |
# File 'lib/paginated_collection/base.rb', line 4 def pagination @pagination end |
Class Method Details
.build_with(elems, pagination: {}, &block) ⇒ Object
16 17 18 19 |
# File 'lib/paginated_collection/base.rb', line 16 def self.build_with(elems, pagination: {}, &block) members = elems.map { |e| block.call(e) } new(*members, pagination: pagination) end |