Class: Forceps::ActsAsCopyableModel::DeepCopier

Inherits:
Object
  • Object
show all
Defined in:
lib/forceps/acts_as_copyable_model.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ DeepCopier

Returns a new instance of DeepCopier.



27
28
29
30
31
32
# File 'lib/forceps/acts_as_copyable_model.rb', line 27

def initialize(options)
  @copied_remote_objects = {}
  @reused_local_objects = Set.new
  @options = options
  @level = 0
end

Instance Attribute Details

#copied_remote_objectsObject

Returns the value of attribute copied_remote_objects.



25
26
27
# File 'lib/forceps/acts_as_copyable_model.rb', line 25

def copied_remote_objects
  @copied_remote_objects
end

#levelObject

Returns the value of attribute level.



25
26
27
# File 'lib/forceps/acts_as_copyable_model.rb', line 25

def level
  @level
end

#optionsObject

Returns the value of attribute options.



25
26
27
# File 'lib/forceps/acts_as_copyable_model.rb', line 25

def options
  @options
end

#reused_local_objectsObject

Returns the value of attribute reused_local_objects.



25
26
27
# File 'lib/forceps/acts_as_copyable_model.rb', line 25

def reused_local_objects
  @reused_local_objects
end

Instance Method Details

#copy(remote_object) ⇒ Object



34
35
36
# File 'lib/forceps/acts_as_copyable_model.rb', line 34

def copy(remote_object)
  cached_local_copy(remote_object) || perform_copy(remote_object)
end