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.



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

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



27
28
29
# File 'lib/active_model_serializers/adapter/json_api/meta.rb', line 27

def as_json
  @value
end