Class: Contrast::Agent::Assess::Policy::Propagator::Append

Inherits:
Base
  • Object
show all
Defined in:
lib/contrast/agent/assess/policy/propagator/append.rb

Overview

Propagation that results in all the tags of the source being applied to the end of the target. The target’s preexisting tags are unaffected beyond any merging of overlapping tags.

Class Method Summary collapse

Methods inherited from Base

find_source, tracked_value?

Class Method Details

.propagate(propagation_node, preshift, target) ⇒ Object

For the source, append its tags to the target. if the target length is greater than the source copy tags from the param to the target in chunks of param size or less if param is appended in space less than param length



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

def propagate propagation_node, preshift, target
  return unless (properties = Contrast::Agent::Assess::Tracker.properties!(target))

  sources = propagation_node.sources
  source1 = find_source(sources[0], preshift)
  # Some appends have two args. If they don't this is probably something
  # obnoxious, like String.*
  source2 = sources[1] ? find_source(sources[1], preshift) : source1

  # if the object and the return are the same length just copy the tags
  # from the object(since nothing from args was added to return)
  if source1.length == target.length
    properties.copy_from(source1, target, 0, propagation_node.untags)
  else
    handle_append(propagation_node, source1, source2, target, properties)
  end
  properties.cleanup_tags
end