Class: Puppet::Pops::Types::RecursionGuard Private

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/pops/types/recursion_guard.rb

Overview

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

API:

  • private

Constant Summary collapse

NO_SELF_RECURSION =

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

API:

  • private

0
SELF_RECURSION_IN_THIS =

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

API:

  • private

1
SELF_RECURSION_IN_THAT =

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

API:

  • private

2
SELF_RECURSION_IN_BOTH =

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

API:

  • private

3

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRecursionGuard

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.

Returns a new instance of RecursionGuard.

API:

  • private



19
20
21
# File 'lib/puppet/pops/types/recursion_guard.rb', line 19

def initialize
  @state = NO_SELF_RECURSION
end

Instance Attribute Details

#stateObject (readonly)

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.

API:

  • private



12
13
14
# File 'lib/puppet/pops/types/recursion_guard.rb', line 12

def state
  @state
end

Instance Method Details

#add_that(instance) ⇒ Integer

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 ‘that’ and return the resulting state

Parameters:

  • the instance to add

Returns:

  • the resulting state

API:

  • private



50
51
52
53
54
55
# File 'lib/puppet/pops/types/recursion_guard.rb', line 50

def add_that(instance)
  if (@state & SELF_RECURSION_IN_THAT) == 0
    @state = @state | SELF_RECURSION_IN_THAT if map_put(that_map, instance)
  end
  @state
end

#add_this(instance) ⇒ Integer

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’ and return the resulting state

Parameters:

  • the instance to add

Returns:

  • the resulting state

API:

  • private



40
41
42
43
44
45
# File 'lib/puppet/pops/types/recursion_guard.rb', line 40

def add_this(instance)
  if (@state & SELF_RECURSION_IN_THIS) == 0
    @state = @state | SELF_RECURSION_IN_THIS if map_put(this_map, instance)
  end
  @state
end

#recursive_that?(instance) ⇒ Integer

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.

Checks if recursion was detected for the given argument in the ‘that’ context

Parameters:

  • the instance to check

Returns:

  • the resulting state

API:

  • private



33
34
35
# File 'lib/puppet/pops/types/recursion_guard.rb', line 33

def recursive_that?(instance)
  that_map[instance.object_id] == true
end

#recursive_this?(instance) ⇒ Integer

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.

Checks if recursion was detected for the given argument in the ‘this’ context

Parameters:

  • the instance to check

Returns:

  • the resulting state

API:

  • private



26
27
28
# File 'lib/puppet/pops/types/recursion_guard.rb', line 26

def recursive_this?(instance)
  this_map[instance.object_id] == true
end