Method: Puppet::Pops::Types::RecursionGuard#with_this

Defined in:
lib/puppet/pops/types/recursion_guard.rb

#with_this(instance) {|@state| ... } ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Add the given argument as ‘this’ invoke the given block with the resulting state

Parameters:

  • instance (Object)

    the instance to add

Yields:

Returns:

  • (Object)

    the result of yielding



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/puppet/pops/types/recursion_guard.rb', line 40

def with_this(instance)
  if (@state & SELF_RECURSION_IN_THIS) == 0
    tc = this_count
    @state = @state | SELF_RECURSION_IN_THIS if this_put(instance)
    if tc < this_count
      # recursive state detected
      result = yield(@state)

      # pop state
      @state &= ~SELF_RECURSION_IN_THIS
      @this_map.delete(instance.object_id)
      return result
    end
  end
  yield(@state)
end