Class: Contrast::Agent::Assess::PreShift
- Includes:
- Components::Interface
- Defined in:
- lib/contrast/agent/assess/policy/preshift.rb,
ext/cs__contrast_patch/cs__contrast_patch.c
Overview
In order to properly shift tags to account for the changes this method caused, we’ll need to store the state before the change occurred.
Constant Summary collapse
- UNDUPLICABLE_MODULES =
[ Enumerator # dup'ing results in 'can't copy execution context' ].cs__freeze
Instance Attribute Summary collapse
-
#arg_lengths ⇒ Object
Returns the value of attribute arg_lengths.
-
#args ⇒ Object
Returns the value of attribute args.
-
#object ⇒ Object
Returns the value of attribute object.
-
#object_length ⇒ Object
Returns the value of attribute object_length.
Class Method Summary collapse
-
.build_preshift(propagation_node, object, args) ⇒ Contrast::Agent::Assess::PreShift?
Save the state before we do the propagation.
Methods included from Components::Interface
Instance Attribute Details
#arg_lengths ⇒ Object
Returns the value of attribute arg_lengths.
19 20 21 |
# File 'lib/contrast/agent/assess/policy/preshift.rb', line 19 def arg_lengths @arg_lengths end |
#args ⇒ Object
Returns the value of attribute args.
19 20 21 |
# File 'lib/contrast/agent/assess/policy/preshift.rb', line 19 def args @args end |
#object ⇒ Object
Returns the value of attribute object.
19 20 21 |
# File 'lib/contrast/agent/assess/policy/preshift.rb', line 19 def object @object end |
#object_length ⇒ Object
Returns the value of attribute object_length.
19 20 21 |
# File 'lib/contrast/agent/assess/policy/preshift.rb', line 19 def object_length @object_length end |
Class Method Details
.build_preshift(propagation_node, object, args) ⇒ Contrast::Agent::Assess::PreShift?
Save the state before we do the propagation. This is one of the few things that we’ll call BEFORE calling the original method. Unfortunately, we may waste some time here if the method then throws an exception, but hey, it threw an exception. These few extra objects aren’t the real problem in that case.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/contrast/agent/assess/policy/preshift.rb', line 38 def build_preshift propagation_node, object, args return nil unless propagation_node return nil unless ASSESS.enabled? initializing = propagation_node.method_name == :initialize return nil if unsafe_io_object?(object, initializing) needs_object = propagation_node.needs_object? needs_args = propagation_node.needs_args? preshift = Contrast::Agent::Assess::PreShift.new append_object_details(preshift, initializing, object) if needs_object append_arg_details(preshift, args) if needs_args preshift rescue StandardError => e logger.error('Unable to build preshift for method.', e) nil end |