This subclass of {Puppet::Property} manages an unordered list of values. For an ordered list see {Puppet::Property::OrderedList}.
# File lib/puppet/property/list.rb, line 27 def add_should_with_current(should, current) should += current if current.is_a?(Array) should.uniq end
dearrayify was motivated because to simplify the implementation of the OrderedList property
# File lib/puppet/property/list.rb, line 37 def dearrayify(array) array.sort.join(delimiter) end
# File lib/puppet/property/list.rb, line 51 def delimiter "," end
# File lib/puppet/property/list.rb, line 32 def inclusive? @resource[membership] == :inclusive end
# File lib/puppet/property/list.rb, line 71 def insync?(is) return true unless is (prepare_is_for_comparison(is) == self.should) end
# File lib/puppet/property/list.rb, line 15 def is_to_s(currentvalue) if currentvalue == :absent return "absent" else return currentvalue.join(delimiter) end end
# File lib/puppet/property/list.rb, line 23 def membership :membership end
# File lib/puppet/property/list.rb, line 64 def prepare_is_for_comparison(is) if is == :absent is = [] end dearrayify(is) end
# File lib/puppet/property/list.rb, line 55 def retrieve #ok, some 'convention' if the list property is named groups, provider should implement a groups method if tmp = provider.send(name) and tmp != :absent return tmp.split(delimiter) else return :absent end end
# File lib/puppet/property/list.rb, line 41 def should return nil unless @should members = @should #inclusive means we are managing everything so if it isn't in should, its gone members = add_should_with_current(members, retrieve) if ! inclusive? dearrayify(members) end
# File lib/puppet/property/list.rb, line 10 def should_to_s(should_value) #just return the should value should_value end