Sha256: 36b251a0421594f0d49e43eff5d6857d0d8152221be52049a1b7e96409c5ba66
Contents?: true
Size: 546 Bytes
Versions: 3
Compression:
Stored size: 546 Bytes
Contents
module Amoeba module Macros class HasOne < ::Amoeba::Macros::Base def follow(relation_name, association) return if association.is_a?(::ActiveRecord::Reflection::ThroughReflection) old_obj = @old_object.__send__(relation_name) return unless old_obj copy_of_obj = old_obj.amoeba_dup(@options) copy_of_obj[:"#{association.foreign_key}"] = nil relation_name = remapped_relation_name(relation_name) @new_object.__send__(:"#{relation_name}=", copy_of_obj) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
amoeba-3.2.0 | lib/amoeba/macros/has_one.rb |
amoeba-3.1.0 | lib/amoeba/macros/has_one.rb |
amoeba-3.0.0 | lib/amoeba/macros/has_one.rb |