Class: ActiveModelSerializers::Adapter::JsonApi::PaginationLinks
- Inherits:
-
Object
- Object
- ActiveModelSerializers::Adapter::JsonApi::PaginationLinks
- Defined in:
- lib/active_model_serializers/adapter/json_api/pagination_links.rb
Constant Summary collapse
- MissingSerializationContextError =
Class.new(KeyError)
- 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
- #as_json ⇒ Object
-
#initialize(collection, adapter_options) ⇒ PaginationLinks
constructor
A new instance of PaginationLinks.
Constructor Details
#initialize(collection, adapter_options) ⇒ PaginationLinks
Returns a new instance of PaginationLinks.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/active_model_serializers/adapter/json_api/pagination_links.rb', line 12 def initialize(collection, ) @collection = collection @adapter_options = @context = .fetch(:serialization_context) do fail MissingSerializationContextError, <<-EOF.freeze JsonApi::PaginationLinks requires a ActiveModelSerializers::SerializationContext. Please pass a ':serialization_context' option or override CollectionSerializer#paginated? to return 'false'. EOF end end |
Instance Attribute Details
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
10 11 12 |
# File 'lib/active_model_serializers/adapter/json_api/pagination_links.rb', line 10 def collection @collection end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
10 11 12 |
# File 'lib/active_model_serializers/adapter/json_api/pagination_links.rb', line 10 def context @context end |
Instance Method Details
#as_json ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/active_model_serializers/adapter/json_api/pagination_links.rb', line 24 def as_json { self: location_url, first: first_page_url, prev: prev_page_url, next: next_page_url, last: last_page_url } end |