Class: Puppet::Property::List
- Defined in:
- lib/puppet/property/list.rb
Overview
This subclass of Puppet::Property manages an unordered list of values. For an ordered list see OrderedList.
Direct Known Subclasses
Instance Method Summary collapse
- #add_should_with_current(should, current) ⇒ Object
-
#dearrayify(array) ⇒ Object
dearrayify was motivated because to simplify the implementation of the OrderedList property.
- #delimiter ⇒ Object
- #inclusive? ⇒ Boolean
- #insync?(is) ⇒ Boolean
-
#is_to_s(currentvalue) ⇒ Object
rubocop:disable Naming/PredicatePrefix.
- #membership ⇒ Object
- #prepare_is_for_comparison(is) ⇒ Object
- #retrieve ⇒ Object
- #should ⇒ Object
Instance Method Details
#add_should_with_current(should, current) ⇒ Object
19 20 21 22 |
# File 'lib/puppet/property/list.rb', line 19 def add_should_with_current(should, current) should += current if current.is_a?(Array) should.uniq end |
#dearrayify(array) ⇒ Object
dearrayify was motivated because to simplify the implementation of the OrderedList property
29 30 31 |
# File 'lib/puppet/property/list.rb', line 29 def dearrayify(array) array.sort.join(delimiter) end |
#inclusive? ⇒ Boolean
24 25 26 |
# File 'lib/puppet/property/list.rb', line 24 def inclusive? @resource[membership] == :inclusive end |
#insync?(is) ⇒ Boolean
64 65 66 67 68 |
# File 'lib/puppet/property/list.rb', line 64 def insync?(is) return true unless is (prepare_is_for_comparison(is) == should) end |
#is_to_s(currentvalue) ⇒ Object
rubocop:disable Naming/PredicatePrefix
11 12 13 |
# File 'lib/puppet/property/list.rb', line 11 def is_to_s(currentvalue) # rubocop:disable Naming/PredicatePrefix currentvalue == :absent ? super(currentvalue) : currentvalue.join(delimiter) end |
#membership ⇒ Object
15 16 17 |
# File 'lib/puppet/property/list.rb', line 15 def membership :membership end |
#prepare_is_for_comparison(is) ⇒ Object
57 58 59 60 61 62 |
# File 'lib/puppet/property/list.rb', line 57 def prepare_is_for_comparison(is) if is == :absent is = [] end dearrayify(is) end |
#retrieve ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/puppet/property/list.rb', line 47 def retrieve # ok, some 'convention' if the list property is named groups, provider should implement a groups method tmp = provider.send(name) if provider if tmp && tmp != :absent tmp.instance_of?(Array) ? tmp : tmp.split(delimiter) else :absent end end |
#should ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/puppet/property/list.rb', line 33 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) unless inclusive? dearrayify(members) end |