class Puppet::Property::List
This subclass of {Puppet::Property} manages an unordered list of values. For an ordered list see {Puppet::Property::OrderedList}.
Public Instance Methods
add_should_with_current(should, current)
click to toggle source
# File lib/puppet/property/list.rb 19 def add_should_with_current(should, current) 20 should += current if current.is_a?(Array) 21 should.uniq 22 end
dearrayify(array)
click to toggle source
dearrayify was motivated because to simplify the implementation of the OrderedList property
# File lib/puppet/property/list.rb 29 def dearrayify(array) 30 array.sort.join(delimiter) 31 end
delimiter()
click to toggle source
# File lib/puppet/property/list.rb 43 def delimiter 44 "," 45 end
inclusive?()
click to toggle source
# File lib/puppet/property/list.rb 24 def inclusive? 25 @resource[membership] == :inclusive 26 end
insync?(is)
click to toggle source
# File lib/puppet/property/list.rb 64 def insync?(is) 65 return true unless is 66 67 (prepare_is_for_comparison(is) == self.should) 68 end
is_to_s(currentvalue)
click to toggle source
Calls superclass method
Puppet::Property#is_to_s
# File lib/puppet/property/list.rb 11 def is_to_s(currentvalue) 12 currentvalue == :absent ? super(currentvalue) : currentvalue.join(delimiter) 13 end
membership()
click to toggle source
# File lib/puppet/property/list.rb 15 def membership 16 :membership 17 end
prepare_is_for_comparison(is)
click to toggle source
# File lib/puppet/property/list.rb 57 def prepare_is_for_comparison(is) 58 if is == :absent 59 is = [] 60 end 61 dearrayify(is) 62 end
retrieve()
click to toggle source
# File lib/puppet/property/list.rb 47 def retrieve 48 #ok, some 'convention' if the list property is named groups, provider should implement a groups method 49 tmp = provider.send(name) if provider 50 if tmp && tmp != :absent 51 return tmp.instance_of?(Array) ? tmp : tmp.split(delimiter) 52 else 53 return :absent 54 end 55 end
should()
click to toggle source
# File lib/puppet/property/list.rb 33 def should 34 return nil unless @should 35 36 members = @should 37 #inclusive means we are managing everything so if it isn't in should, its gone 38 members = add_should_with_current(members, retrieve) if ! inclusive? 39 40 dearrayify(members) 41 end