Sha256: fc63d06ca752d3e926200d41cb7db29210599b3167ab79febe6cf4edce6dcd62
Contents?: true
Size: 579 Bytes
Versions: 1
Compression:
Stored size: 579 Bytes
Contents
# frozen_string_literal: true 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
amoeba-3.3.0 | lib/amoeba/macros/has_one.rb |