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

Instance Method Summary collapse

Instance Attribute Details

#includes=(value) ⇒ Object

Sets the attribute includes

Parameters:

  • value

    the value to set the attribute includes to.



13
14
15
# File 'lib/jsonapi/materializer/collection.rb', line 13

def includes=(value)
  @includes = value
end

#objectObject

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

Parameters:

  • value

    the value to set the attribute pagination to.



14
15
16
# File 'lib/jsonapi/materializer/collection.rb', line 14

def pagination=(value)
  @pagination = value
end

#selects=(value) ⇒ Object

Sets the attribute selects

Parameters:

  • value

    the value to set the attribute selects to.



12
13
14
# File 'lib/jsonapi/materializer/collection.rb', line 12

def selects=(value)
  @selects = value
end

Instance Method Details

#as_jsonObject



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