Class: Puppet::ConfineCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/confine_collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label) ⇒ ConfineCollection

Returns a new instance of ConfineCollection.



29
30
31
32
# File 'lib/puppet/confine_collection.rb', line 29

def initialize(label)
  @label = label
  @confines = []
end

Instance Attribute Details

#labelObject (readonly)

Returns the value of attribute label.



28
29
30
# File 'lib/puppet/confine_collection.rb', line 28

def label
  @label
end

Instance Method Details

#confine(hash) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/puppet/confine_collection.rb', line 7

def confine(hash)
  if hash.include?(:for_binary)
    for_binary = true
    hash.delete(:for_binary)
  else
    for_binary = false
  end
  hash.each do |test, values|
    klass = Puppet::Confine.test(test)
    if klass
      @confines << klass.new(values)
      @confines[-1].for_binary = true if for_binary
    else
      confine = Puppet::Confine.test(:variable).new(values)
      confine.name = test
      @confines << confine
    end
    @confines[-1].label = self.label
  end
end

#summaryObject

Return a hash of the whole confine set, used for the Provider reference.



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/puppet/confine_collection.rb', line 36

def summary
  confines = Hash.new { |hash, key| hash[key] = [] }
  @confines.each { |confine| confines[confine.class] << confine }
  result = {}
  confines.each do |klass, list|
    value = klass.summarize(list)
    next if (value.respond_to?(:length) and value.length == 0) or (value == 0)
    result[klass.name] = value

  end
  result
end

#valid?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/puppet/confine_collection.rb', line 49

def valid?
  ! @confines.detect { |c| ! c.valid? }
end