Module: Contrast::Agent::Assess::Property::Updated

Included in:
Contrast::Agent::Assess::Properties
Defined in:
lib/contrast/agent/assess/property/updated.rb

Overview

This module serves to hold the functionality required for the update of properties as they go through dataflow.

Instance Method Summary collapse

Instance Method Details

#copy_from(source, owner, shift = 0, skip_tags = nil) ⇒ Object

copy tags and info from source’s properties to self

Parameters:

  • source (Object)

    the object from which existing properties should be copied.

  • owner (Object)

    the object to which these properties apply.

  • shift (Integer) (defaults to: 0)

    (0) how far to shift the tags during copy, useful for insert and append operations.

  • skip_tags (Set<String>) (defaults to: nil)

    (nil) the tags to not copy over, useful for propagation events that have ‘untags’.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/contrast/agent/assess/property/updated.rb', line 21

def copy_from source, owner, shift = 0, skip_tags = nil
  return if owner.equal?(source)
  return unless Contrast::Agent::Assess::Tracker.tracked?(source)

  original = Contrast::Agent::Assess::Tracker.properties(source)
  return unless original

  adjust_duplicate(original)
  original.tag_keys.each do |key|
    next if skip_tags&.include?(key)

    existing = tags[key]
    had_existing = existing.any?
    value = original.fetch_tag(key)
    value.each do |tag|
      existing << tag.copy_modified(shift)
    end
    Contrast::Utils::TagUtil.size_aware_merge(owner, existing) if had_existing
  end
end

#splat_from(source, owner) ⇒ Object

Some propagation occurred, but we’re not sure what the exact transformation was. To be safe, we just explode all the tags from the source to the return.

If the return already had that tag, the existing tag range is recycled to save us an object.

Parameters:

  • source (Object)

    the object from which existing properties should be copied.

  • owner (Object)

    the object to which these properties apply.



52
53
54
55
56
57
58
59
# File 'lib/contrast/agent/assess/property/updated.rb', line 52

def splat_from source, owner
  splat_length = Contrast::Utils::StringUtils.ret_length(owner)
  return if splat_length.zero?

  splat_from_ret(splat_length)
  splat_from_source(source, splat_length)
  cleanup_tags
end