Module: JSONAPI::Materializer::Collection
- Extended by:
- ActiveSupport::Concern
- Includes:
- ActiveModel::Model
- Defined in:
- lib/jsonapi/materializer/collection.rb
Constant Summary collapse
- SELF_TEMPLATE =
"{origin}/{type}"
Instance Attribute Summary collapse
-
#includes ⇒ Object
writeonly
Sets the attribute includes.
-
#object ⇒ Object
Returns the value of attribute object.
-
#pagination ⇒ Object
writeonly
Sets the attribute pagination.
-
#selects ⇒ Object
writeonly
Sets the attribute selects.
Instance Method Summary collapse
Instance Attribute Details
#includes=(value) ⇒ Object
Sets the attribute includes
13 14 15 |
# File 'lib/jsonapi/materializer/collection.rb', line 13 def includes=(value) @includes = value end |
#object ⇒ Object
Returns the value of attribute object.
11 12 13 |
# File 'lib/jsonapi/materializer/collection.rb', line 11 def object @object end |
#pagination=(value) ⇒ Object
Sets the attribute pagination
14 15 16 |
# File 'lib/jsonapi/materializer/collection.rb', line 14 def pagination=(value) @pagination = value end |
#selects=(value) ⇒ Object
Sets the attribute selects
12 13 14 |
# File 'lib/jsonapi/materializer/collection.rb', line 12 def selects=(value) @selects = value end |
Instance Method Details
#as_json ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/jsonapi/materializer/collection.rb', line 16 def as_json(*) { links: pagination, included:, meta: }.transform_values(&:presence).compact.merge(data: resources) end |