Class: Contrast::Agent::Assess::Tracker
- Defined in:
- lib/contrast/agent/assess/tracker.rb,
ext/cs__assess_string/cs__assess_string.c,
ext/cs__assess_marshal_module/cs__assess_marshal_module.c
Overview
How we track the Assess properties attached to objects
Finalized objects should run through this class as the Finalizers have tightly coupled dependencies on each other.
Constant Summary collapse
- PROPERTIES_HASH =
Contrast::Agent::Assess::Finalizers::Hash.new
Class Method Summary collapse
-
.copy(source, target) ⇒ Object
Copy the properties from one object to the next, assuming the target does not already have its own properties.
-
.duplicate(source) ⇒ Object
Duplicate the given object, returning the duplicate after copying the properties of the original and storing them as the properties of the duplicate.
- .pre_freeze(source) ⇒ Object
- .properties(source) ⇒ Object
- .trackable?(source) ⇒ Boolean
- .tracked?(source) ⇒ Boolean
Class Method Details
.copy(source, target) ⇒ Object
Copy the properties from one object to the next, assuming the target does not already have its own properties.
40 41 42 |
# File 'lib/contrast/agent/assess/tracker.rb', line 40 def copy source, target PROPERTIES_HASH[target] ||= properties(source).dup end |
.duplicate(source) ⇒ Object
Duplicate the given object, returning the duplicate after copying the properties of the original and storing them as the properties of the duplicate.
51 52 53 54 55 56 57 58 59 |
# File 'lib/contrast/agent/assess/tracker.rb', line 51 def duplicate source return source unless source duplicate = source.dup PROPERTIES_HASH[duplicate] ||= PROPERTIES_HASH[source].dup duplicate rescue StandardError source end |
.pre_freeze(source) ⇒ Object
31 32 33 |
# File 'lib/contrast/agent/assess/tracker.rb', line 31 def pre_freeze source PROPERTIES_HASH.pre_freeze(source) end |
.properties(source) ⇒ Object
17 18 19 20 21 |
# File 'lib/contrast/agent/assess/tracker.rb', line 17 def properties source return unless trackable?(source) PROPERTIES_HASH[source] ||= Contrast::Agent::Assess::Properties.new end |
.trackable?(source) ⇒ Boolean
23 24 25 |
# File 'lib/contrast/agent/assess/tracker.rb', line 23 def trackable? source PROPERTIES_HASH.trackable?(source) end |
.tracked?(source) ⇒ Boolean
27 28 29 |
# File 'lib/contrast/agent/assess/tracker.rb', line 27 def tracked? source PROPERTIES_HASH.tracked?(source) end |