Class: ActiveModelSerializers::Adapter::JsonApi::Meta

Inherits:
Object
  • Object
show all
Defined in:
lib/active_model_serializers/adapter/json_api/meta.rb

Overview

meta definition:

JSON Object

description:

Non-standard meta-information that can not be represented as an attribute or relationship.

structure:

{
  attitude: 'adjustable'
}

Instance Method Summary collapse

Constructor Details

#initialize(serializer) ⇒ Meta

Returns a new instance of Meta.



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/active_model_serializers/adapter/json_api/meta.rb', line 17

def initialize(serializer)
  @object = serializer.object
  @scope = serializer.scope

  # Use the return value of the block unless it is nil.
  if serializer._meta.respond_to?(:call)
    @value = instance_eval(&serializer._meta)
  else
    @value = serializer._meta
  end
end

Instance Method Details

#as_jsonObject



29
30
31
# File 'lib/active_model_serializers/adapter/json_api/meta.rb', line 29

def as_json
  @value
end