Class: Couchbase::Model::DeepCopier

Inherits:
Object
  • Object
show all
Defined in:
lib/couchbase/model/deep_copier.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source) ⇒ DeepCopier

Returns a new instance of DeepCopier.



5
6
7
# File 'lib/couchbase/model/deep_copier.rb', line 5

def initialize(source)
  @source = source
end

Instance Attribute Details

#sourceObject (readonly)

Returns the value of attribute source.



4
5
6
# File 'lib/couchbase/model/deep_copier.rb', line 4

def source
  @source
end

Instance Method Details

#copyObject



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/couchbase/model/deep_copier.rb', line 9

def copy
  if cloneable?
    if complex?
      deep_copy
    else
      source.clone
    end
  else
    source
  end
end