Class: JSONAPI::Ruby::Deserializer::Relationships

Inherits:
Object
  • Object
show all
Includes:
Parser
Defined in:
lib/jsonapi-ruby-deserializer/relationships.rb

Instance Attribute Summary collapse

Attributes included from Parser

#to_h

Instance Method Summary collapse

Methods included from Parser

#parse!

Constructor Details

#initialize(data) ⇒ Relationships

Returns a new instance of Relationships.



12
13
14
15
16
17
18
19
# File 'lib/jsonapi-ruby-deserializer/relationships.rb', line 12

def initialize(data)
  @to_a = []
  data.map do |key, h|
    @to_a << key
    self.class.send(:attr_accessor, key)
    instance_variable_set("@#{key}", Document.new(h))
  end
end

Instance Attribute Details

#to_aObject

Returns the value of attribute to_a.



10
11
12
# File 'lib/jsonapi-ruby-deserializer/relationships.rb', line 10

def to_a
  @to_a
end