Sha256: 68f93f34999cbeefaa21163efe8834f49c85d66ed3966d41b700acd042b0036c
Contents?: true
Size: 783 Bytes
Versions: 1
Compression:
Stored size: 783 Bytes
Contents
module AxleAttributes module Serializations class SerializeOne < Serialization def writer(record_or_hash) if record_or_hash.is_a?(Hash) if target target.attributes = record_or_hash record = target else record = reflection.klass.new(record_or_hash) end else record = record_or_hash end self.target = record end def attributes_writer(attributes) attributes = attributes.with_indifferent_access writer(attributes['_destroy'] == '1' ? nil : attributes) end private def instantiate_target(json) if json reflection.klass.instantiate json['id'], json end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
axle_attributes-1.13.2 | lib/axle_attributes/serializations/serialize_one.rb |