Module: Contrast::Agent::Assess::Policy::Propagator::Trim

Defined in:
lib/contrast/agent/assess/policy/propagator/trim.rb

Overview

This class is specifically for String#tr(_s) propagation

Disclaimer: there may be a better way, but we’re in a ‘get it work’ state. hopefully, we’ll be in a ‘get it right’ state soon.

Class Method Summary collapse

Class Method Details

.tr_s_tagger(patcher, preshift, ret, _block) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/contrast/agent/assess/policy/propagator/trim.rb', line 36

def tr_s_tagger patcher, preshift, ret, _block
  return unless ret && !ret.empty?
  return unless (properties = Contrast::Agent::Assess::Tracker.properties!(ret))

  source = preshift.object
  args = preshift.args
  properties.splat_from(source, ret)
  event_data = Contrast::Agent::Assess::Events::EventData.new(patcher, ret, source, ret, args)
  properties.build_event(event_data)
  ret
end

.tr_tagger(policy_node, preshift, ret, _block) ⇒ nil, String

Returns ret.

Parameters:

Returns:



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/contrast/agent/assess/policy/propagator/trim.rb', line 21

def tr_tagger policy_node, preshift, ret, _block
  return ret unless ret && !ret.empty?
  return ret unless (properties = Contrast::Agent::Assess::Tracker.properties!(ret))

  properties.copy_from(preshift.object, ret)
  handle_tr(policy_node, preshift, ret, properties)
  event_data = Contrast::Agent::Assess::Events::EventData.new(policy_node,
                                                              ret,
                                                              preshift.object,
                                                              ret,
                                                              preshift.args)
  properties.build_event(event_data, 1)
  ret
end