Module: DeepDive
- Includes:
- API
- Defined in:
- lib/deep_dive/deep_dive.rb
Defined Under Namespace
Modules: API, CMeth
Classes: DeepDiveException
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from API
#dclone, #ddup
Class Method Details
.included(base) ⇒ Object
153
154
155
|
# File 'lib/deep_dive/deep_dive.rb', line 153
def self.included(base)
base.extend(CMeth)
end
|
.inherited(sub) ⇒ Object
157
158
159
|
# File 'lib/deep_dive/deep_dive.rb', line 157
def self.inherited(sub)
sub.include(DeepDive)
end
|
.verbose=(t) ⇒ Object
21
22
23
|
# File 'lib/deep_dive/deep_dive.rb', line 21
def self.verbose=(t)
@@verbosity = t
end
|
.verbose? ⇒ Boolean
25
26
27
|
# File 'lib/deep_dive/deep_dive.rb', line 25
def self.verbose?
defined?(@@verbosity) && @@verbosity
end
|
Instance Method Details
#_replicate(dupit: true, oc: {}) ⇒ Object
Not meant to be called externally. Use either ddup or dclone.
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/deep_dive/deep_dive.rb', line 52
def _replicate(dupit: true, oc: {})
unless oc.member? self
puts "DeepDive: replicating #{self.class}" if DeepDive::verbose?
copy = oc[self] = if dupit
dup
else
clone
end
copy.instance_variables.map do |var|
[var, instance_variable_get(var)]
end.reject do |var, ob|
not ob.respond_to? :_replicate
end.reject do |var, ob|
self.class.excluded?(var, self)
end.each do |var, value|
puts "DeepDive: rep instance var #{self.class}.#{var}" if DeepDive::verbose?
copy.instance_variable_set(var, value._replicate(oc: oc, dupit: dupit))
end
end
oc[self]
end
|