summaryrefslogtreecommitdiffstats
path: root/lib/puppet/property
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/property')
-rw-r--r--lib/puppet/property/list.rb9
-rw-r--r--lib/puppet/property/ordered_list.rb22
2 files changed, 29 insertions, 2 deletions
diff --git a/lib/puppet/property/list.rb b/lib/puppet/property/list.rb
index 4e7f6ec90..0c933f164 100644
--- a/lib/puppet/property/list.rb
+++ b/lib/puppet/property/list.rb
@@ -28,6 +28,11 @@ module Puppet
@resource[membership] == :inclusive
end
+ #dearrayify was motivated because to simplify the implementation of the OrderedList property
+ def dearrayify(array)
+ array.sort.join(delimiter)
+ end
+
def should
unless defined? @should and @should
return nil
@@ -39,7 +44,7 @@ module Puppet
members = add_should_with_current(members, retrieve)
end
- members.sort.join(delimiter)
+ dearrayify(members)
end
def delimiter
@@ -57,7 +62,7 @@ module Puppet
def prepare_is_for_comparison(is)
if is.is_a? Array
- is = is.sort.join(delimiter)
+ is = dearrayify(is)
end
is
end
diff --git a/lib/puppet/property/ordered_list.rb b/lib/puppet/property/ordered_list.rb
new file mode 100644
index 000000000..816b16c48
--- /dev/null
+++ b/lib/puppet/property/ordered_list.rb
@@ -0,0 +1,22 @@
+require 'puppet/property/list'
+
+module Puppet
+ class Property
+ class OrderedList < List
+
+ def add_should_with_current(should, current)
+ if current.is_a?(Array)
+ #tricky trick
+ #Preserve all the current items in the list
+ #but move them to the back of the line
+ should = should + (current - should)
+ end
+ should
+ end
+
+ def dearrayify(array)
+ array.join(delimiter)
+ end
+ end
+ end
+end