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 18 def add_should_with_current(should, current) 19 should += current if current.is_a?(Array) 20 should.uniq 21 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 28 def dearrayify(array) 29 array.sort.join(delimiter) 30 end
delimiter()
click to toggle source
# File lib/puppet/property/list.rb 42 def delimiter 43 "," 44 end
inclusive?()
click to toggle source
# File lib/puppet/property/list.rb 23 def inclusive? 24 @resource[membership] == :inclusive 25 end
insync?(is)
click to toggle source
# File lib/puppet/property/list.rb 63 def insync?(is) 64 return true unless is 65 66 (prepare_is_for_comparison(is) == self.should) 67 end
is_to_s(currentvalue)
click to toggle source
Calls superclass method
Puppet::Property#is_to_s
# File lib/puppet/property/list.rb 10 def is_to_s(currentvalue) 11 currentvalue == :absent ? super(currentvalue) : currentvalue.join(delimiter) 12 end
membership()
click to toggle source
# File lib/puppet/property/list.rb 14 def membership 15 :membership 16 end
prepare_is_for_comparison(is)
click to toggle source
# File lib/puppet/property/list.rb 56 def prepare_is_for_comparison(is) 57 if is == :absent 58 is = [] 59 end 60 dearrayify(is) 61 end
retrieve()
click to toggle source
# File lib/puppet/property/list.rb 46 def retrieve 47 #ok, some 'convention' if the list property is named groups, provider should implement a groups method 48 tmp = provider.send(name) if provider 49 if tmp && tmp != :absent 50 return tmp.instance_of?(Array) ? tmp : tmp.split(delimiter) 51 else 52 return :absent 53 end 54 end
should()
click to toggle source
# File lib/puppet/property/list.rb 32 def should 33 return nil unless @should 34 35 members = @should 36 #inclusive means we are managing everything so if it isn't in should, its gone 37 members = add_should_with_current(members, retrieve) if ! inclusive? 38 39 dearrayify(members) 40 end