Module: JsonAPIObjectMapper::Deserialize::DSL::ClassMethods
- Defined in:
- lib/jsonapi-object-mapper/deserialize/dsl.rb
Instance Method Summary collapse
- #initialize(*args) ⇒ Object
- #to_hash ⇒ Object (also: #to_h)
- #to_s ⇒ Object
Instance Method Details
#initialize(*args) ⇒ Object
40 41 42 43 44 |
# File 'lib/jsonapi-object-mapper/deserialize/dsl.rb', line 40 def initialize(*args) @_class_attributes = {} @_class_relationships = {} super end |
#to_hash ⇒ Object Also known as: to_h
46 47 48 49 50 51 |
# File 'lib/jsonapi-object-mapper/deserialize/dsl.rb', line 46 def to_hash hashed_relationships = @_class_relationships.map do |key, value| { key => value.respond_to?(:to_hash) ? value.to_hash : value } end [@_class_attributes, *hashed_relationships].reduce({}, :merge) end |
#to_s ⇒ Object
54 55 56 |
# File 'lib/jsonapi-object-mapper/deserialize/dsl.rb', line 54 def to_s to_hash.to_s end |