class Agnostic::Duplicate::ChangeSet::ShallowCopy
Defines a changeset where a deep copy wants to be applied to all attributes.
Though if the field value is a memory address it copies the memory address, and if the field value is a primitive type it copies the value of the primitive type.
Public Instance Methods
apply(parent, model)
click to toggle source
Applies changes needed on the duplicated new instance object @param parent [Duplicable] the original object to be duplicated @param model [Duplicable] the duplicated new instance object
# File lib/agnostic/duplicate.rb, line 223 def apply(parent, model) attributes.each do |attribute| copy_attribute(attribute, parent, model) end end
Private Instance Methods
copy_attribute(attribute, parent, model)
click to toggle source
@param attribute [Symbol] attribute to be copied @param parent [Duplicable] the original object to be duplicated @param model [Duplicable] the duplicated new instance object
# File lib/agnostic/duplicate.rb, line 234 def copy_attribute(attribute, parent, model) model.send("#{attribute}=", parent.send(attribute)) rescue raise_copy_error_for(attribute) end