Class: Deserializer::Attribute::HasOneAssociation
- Inherits:
-
Association
- Object
- Base
- Association
- Deserializer::Attribute::HasOneAssociation
- Defined in:
- lib/deserializer/attribute/has_one_association.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Deserializer::Attribute::Base
Instance Method Details
#to_hash(params) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/deserializer/attribute/has_one_association.rb', line 5 def to_hash( params ) return {} unless params.has_key? key value = deserializer.from_params( params[key] ) if object.respond_to? name target = object.send( name ) # has_one :thing, deserializer: ThingDeserializer # # def thing # object # end if target == object.object return value # has_one :thing, deserializer: GnihtDeserializer # # def thing # :some_other_key # end else return { target => value } end else return { name => value } end end |