Method: Contrast::Agent::Assess::Finalizers::Hash#trackable?

Defined in:
lib/contrast/agent/assess/finalizers/hash.rb

#trackable?(key) ⇒ Boolean

Something is trackable if it is not a collection and either not frozen or it was frozen after we put a finalizer on it.

Parameters:

  • key (Object)

    the thing to determine if trackable

Returns:

  • (Boolean)


48
49
50
51
52
53
54
55
56
57
58
# File 'lib/contrast/agent/assess/finalizers/hash.rb', line 48

def trackable? key
  return false unless key
  # Track things in these, not them themselves.
  return false if Contrast::Utils::DuckUtils.iterable_hash?(key)
  return false if Contrast::Utils::DuckUtils.iterable_enumerable?(key)
  # If it's not frozen, we can finalize/ track it.
  return true unless key.cs__frozen?

  # Otherwise, we can only track it if we've finalized it in our freeze patch.
  FROZEN_FINALIZED_IDS.include?(key.__id__)
end