Class: Contrast::Agent::Assess::ContrastObject
- Defined in:
- lib/contrast/agent/assess/contrast_object.rb
Overview
This class is a convenient holder of our version of an Object. It creates a String version of the Object from the original provided and keeps reference to the original’s Tags, letting us determine if it was tracked when we try to report to TeamServer.
TODO: RUBY-1083 determine if this is expensive and/or worth not storing these values directly on ContrastEvent
and passing them around. Args probably make the argument for wrapping them b/c otherwise we'll have to keep
two arrays in synch or make an array of arrays, at which point, we may as well make this.
Instance Attribute Summary collapse
-
#object ⇒ String
readonly
The Contrast String representation of the Object.
-
#object_type ⇒ String
readonly
The name of the Class/Module of the Object.
-
#tags ⇒ Hash<Contrast::Agent::Assess::Tag>
readonly
The tags on the original Object.
-
#tracked_object_id ⇒ Integer
readonly
The __id__ of the original Object.
Instance Method Summary collapse
-
#initialize(object) ⇒ ContrastObject
constructor
Capture the details about the object which we need to render it in TeamServer.
-
#tracked? ⇒ Boolean
Is the object this represents tracked or not?.
Constructor Details
#initialize(object) ⇒ ContrastObject
Capture the details about the object which we need to render it in TeamServer.
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/contrast/agent/assess/contrast_object.rb', line 32 def initialize object if object @object = Contrast::Utils::ClassUtil.to_contrast_string(object) @tracked_object_id = object.__id__ @object_type = object.cs__class.cs__name @tags = Contrast::Agent::Assess::Tracker.properties(object)&. else @object = Contrast::Utils::ObjectShare::NIL_STRING @tracked_object_id = nil.__id__ @object_type = nil.cs__class.cs__name end end |
Instance Attribute Details
#object ⇒ String (readonly)
Returns the Contrast String representation of the Object.
20 21 22 |
# File 'lib/contrast/agent/assess/contrast_object.rb', line 20 def object @object end |
#object_type ⇒ String (readonly)
Returns the name of the Class/Module of the Object.
24 25 26 |
# File 'lib/contrast/agent/assess/contrast_object.rb', line 24 def object_type @object_type end |
#tags ⇒ Hash<Contrast::Agent::Assess::Tag> (readonly)
Returns the tags on the original Object.
26 27 28 |
# File 'lib/contrast/agent/assess/contrast_object.rb', line 26 def @tags end |
#tracked_object_id ⇒ Integer (readonly)
Returns the __id__ of the original Object.
22 23 24 |
# File 'lib/contrast/agent/assess/contrast_object.rb', line 22 def tracked_object_id @tracked_object_id end |
Instance Method Details
#tracked? ⇒ Boolean
Is the object this represents tracked or not?
48 49 50 |
# File 'lib/contrast/agent/assess/contrast_object.rb', line 48 def tracked? !!&.any? end |