Class: Oat::Adapters::BasicJson

Inherits:
Oat::Adapter
  • Object
show all
Defined in:
app/openbel/api/resources/adapters/basic_json.rb

Instance Method Summary collapse

Instance Method Details

#entities(name, collection, serializer_class = nil, context_options = {}, &block) ⇒ Object Also known as: collection



35
36
37
38
39
40
# File 'app/openbel/api/resources/adapters/basic_json.rb', line 35

def entities(name, collection, serializer_class = nil, context_options = {}, &block)
  data[entity_name(name)] = collection.map do |obj|
    entity_serializer = serializer_from_block_or_class(obj, serializer_class, context_options, &block)
    entity_serializer ? entity_serializer.to_hash : nil
  end
end

#entity(name, obj, serializer_class = nil, context_options = {}, &block) ⇒ Object



30
31
32
33
# File 'app/openbel/api/resources/adapters/basic_json.rb', line 30

def entity(name, obj, serializer_class = nil, context_options = {}, &block)
  entity_serializer = serializer_from_block_or_class(obj, serializer_class, context_options, &block)
  data[entity_name(name)] = entity_serializer ? entity_serializer.to_hash : nil
end


4
5
6
# File 'app/openbel/api/resources/adapters/basic_json.rb', line 4

def link(rel, opts = {})
  # no-op to maintain interface compatibility with hypermedia adapters
end

#properties(&block) ⇒ Object



16
17
18
# File 'app/openbel/api/resources/adapters/basic_json.rb', line 16

def properties(&block)
  data.merge! yield_props(&block)
end

#property(key, value) ⇒ Object Also known as: meta



20
21
22
# File 'app/openbel/api/resources/adapters/basic_json.rb', line 20

def property(key, value)
  data[key] = value
end

#rel(rels) ⇒ Object



26
27
28
# File 'app/openbel/api/resources/adapters/basic_json.rb', line 26

def rel(rels)
  # no-op to maintain interface compatibility with the Siren adapter
end