Class: ActiveModel::Serializer::Adapter::JsonApi::PaginationLinks
- Inherits:
-
Object
- Object
- ActiveModel::Serializer::Adapter::JsonApi::PaginationLinks
- Defined in:
- lib/active_model/serializer/adapter/json_api/pagination_links.rb
Constant Summary collapse
- FIRST_PAGE =
1
Instance Attribute Summary collapse
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Instance Method Summary collapse
-
#initialize(collection, context) ⇒ PaginationLinks
constructor
A new instance of PaginationLinks.
- #serializable_hash(options = {}) ⇒ Object
Constructor Details
#initialize(collection, context) ⇒ PaginationLinks
Returns a new instance of PaginationLinks.
6 7 8 9 |
# File 'lib/active_model/serializer/adapter/json_api/pagination_links.rb', line 6 def initialize(collection, context) @collection = collection @context = context end |
Instance Attribute Details
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
4 5 6 |
# File 'lib/active_model/serializer/adapter/json_api/pagination_links.rb', line 4 def collection @collection end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
4 5 6 |
# File 'lib/active_model/serializer/adapter/json_api/pagination_links.rb', line 4 def context @context end |
Instance Method Details
#serializable_hash(options = {}) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/active_model/serializer/adapter/json_api/pagination_links.rb', line 11 def serializable_hash( = {}) pages_from.each_with_object({}) do |(key, value), hash| params = query_parameters.merge(page: { number: value, size: collection.size }).to_query hash[key] = "#{url()}?#{params}" end end |