summaryrefslogtreecommitdiffstats
path: root/lib/puppet/property
diff options
context:
space:
mode:
authorAndrew Shafer <andrew@reductivelabs.com>2008-12-01 00:07:04 -0700
committerJames Turnbull <james@lovedthanlost.net>2008-12-01 20:52:04 +1100
commitfa9820baaebe29675defb14bc9d64f6cb9b75211 (patch)
treebb8720b1f2520f7c6b446000c1f9bdcde05252f5 /lib/puppet/property
parentf6fa4f7b8c85303dd801fa6e4c5f47845af53c54 (diff)
downloadpuppet-fa9820baaebe29675defb14bc9d64f6cb9b75211.tar.gz
puppet-fa9820baaebe29675defb14bc9d64f6cb9b75211.tar.xz
puppet-fa9820baaebe29675defb14bc9d64f6cb9b75211.zip
Bug #1778 - Solaris RBAC profiles should maintain order
Created OrderedList property Added to profile property small refactor in List to make inheriting easier
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