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
66 67 68 69 70 |
# File 'lib/jsonapi-object-mapper/deserialize/dsl.rb', line 66 def initialize(*args) @_class_attributes = {} @_class_relationships = {} super end |
#to_hash ⇒ Object Also known as: to_h
72 73 74 75 76 77 |
# File 'lib/jsonapi-object-mapper/deserialize/dsl.rb', line 72 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
80 81 82 |
# File 'lib/jsonapi-object-mapper/deserialize/dsl.rb', line 80 def to_s to_hash.to_s end |