Class: Puppet::Graph::SequentialPrioritizer Private

Inherits:
Prioritizer show all
Defined in:
lib/puppet/graph/sequential_prioritizer.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.

This implements a priority in which keys are given values that will keep them in the same priority in which they priorities are requested. Nested structures (those in which a key is contained within another key) are preserved in such a way that child keys are after the parent and before the key after the parent.

Instance Method Summary collapse

Methods inherited from Prioritizer

#forget, #priority_of, #record_priority_for

Constructor Details

#initializeSequentialPrioritizer

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 SequentialPrioritizer.



11
12
13
14
15
# File 'lib/puppet/graph/sequential_prioritizer.rb', line 11

def initialize
  super
  @container = {}
  @count = Puppet::Graph::Key.new
end

Instance Method Details

#generate_priority_contained_in(container, key) ⇒ 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.



26
27
28
29
30
31
32
# File 'lib/puppet/graph/sequential_prioritizer.rb', line 26

def generate_priority_contained_in(container, key)
  @container[container] ||= priority_of(container).down
  priority = @container[container].next
  record_priority_for(key, priority)
  @container[container] = priority
  priority
end

#generate_priority_for(key) ⇒ 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.



17
18
19
20
21
22
23
24
# File 'lib/puppet/graph/sequential_prioritizer.rb', line 17

def generate_priority_for(key)
  if priority_of(key).nil?
    @count = @count.next
    record_priority_for(key, @count)
  else
    priority_of(key)
  end
end