Class: HALDecorator::Pagination
- Inherits:
-
Object
- Object
- HALDecorator::Pagination
- Defined in:
- lib/hal_decorator/pagination.rb
Overview
TODO: Support Kaminari and Will_paginate
Defined Under Namespace
Classes: Uri
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(serialized, collection) ⇒ Pagination
constructor
A new instance of Pagination.
Constructor Details
#initialize(serialized, collection) ⇒ Pagination
Returns a new instance of Pagination.
53 54 55 56 57 |
# File 'lib/hal_decorator/pagination.rb', line 53 def initialize(serialized, collection) @serialized = serialized @collection = collection @self_uri = Uri.parse serialized.dig(:_links, :self, :href) end |
Class Method Details
.paginate!(serialized, collection) ⇒ Object
49 50 51 |
# File 'lib/hal_decorator/pagination.rb', line 49 def self.paginate!(serialized, collection) new(serialized, collection).call end |
Instance Method Details
#call ⇒ Object
59 60 61 62 63 64 |
# File 'lib/hal_decorator/pagination.rb', line 59 def call return unless should_paginate? add_query_to_self add_prev_link add_next_link end |