Class: Spree::Api::PagyCollection
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Spree::Api::PagyCollection
- Includes:
- Enumerable
- Defined in:
- app/paginators/spree/api/paginate.rb
Overview
Wrapper providing Kaminari-compatible interface for CollectionOptionsHelpers Includes Enumerable so jsonapi-serializer detects it as a collection
Instance Attribute Summary collapse
-
#pagy ⇒ Object
readonly
Returns the value of attribute pagy.
Instance Method Summary collapse
-
#each(&block) ⇒ Object
Enumerable requires #each to be defined.
-
#initialize(records, pagy) ⇒ PagyCollection
constructor
A new instance of PagyCollection.
- #next_page ⇒ Object
- #prev_page ⇒ Object
- #total_count ⇒ Object
- #total_pages ⇒ Object
Constructor Details
#initialize(records, pagy) ⇒ PagyCollection
Returns a new instance of PagyCollection.
41 42 43 44 |
# File 'app/paginators/spree/api/paginate.rb', line 41 def initialize(records, pagy) super(records) @pagy = pagy end |
Instance Attribute Details
#pagy ⇒ Object (readonly)
Returns the value of attribute pagy.
39 40 41 |
# File 'app/paginators/spree/api/paginate.rb', line 39 def pagy @pagy end |
Instance Method Details
#each(&block) ⇒ Object
Enumerable requires #each to be defined
47 48 49 |
# File 'app/paginators/spree/api/paginate.rb', line 47 def each(&block) __getobj__.each(&block) end |
#next_page ⇒ Object
51 52 53 |
# File 'app/paginators/spree/api/paginate.rb', line 51 def next_page @pagy.next end |
#prev_page ⇒ Object
55 56 57 |
# File 'app/paginators/spree/api/paginate.rb', line 55 def prev_page @pagy.previous end |
#total_count ⇒ Object
63 64 65 |
# File 'app/paginators/spree/api/paginate.rb', line 63 def total_count @pagy.count end |
#total_pages ⇒ Object
59 60 61 |
# File 'app/paginators/spree/api/paginate.rb', line 59 def total_pages @pagy.pages end |