Module: Alchemy::JsonApi::EssenceSerializer

Class Method Summary collapse

Class Method Details

.included(klass) ⇒ Object


5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/alchemy/json_api/essence_serializer.rb', line 5

def self.included(klass)
  klass.include JSONAPI::Serializer
  klass.has_one :element, record_type: :element, serializer: ::Alchemy::JsonApi::ElementSerializer do |essence|
    essence.content.element
  end
  klass.attributes :ingredient
  klass.attribute :role do |essence|
    essence.content.name
  end
  klass.attribute :deprecated do |essence|
    !!essence.content.definition[:deprecated]
  end
end