diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-12-19 04:57:57 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-12-19 04:57:57 +0000 |
commit | 9f4870637ce57d548d23c0b3330200014327c268 (patch) | |
tree | b820cfb5a8150dc00d475ffe0cde6316ad210a91 /lib/puppet/util/rails | |
parent | dc5f4dc0d01dc2ccb4679afbf3802a7ab0f3c126 (diff) | |
download | puppet-9f4870637ce57d548d23c0b3330200014327c268.tar.gz puppet-9f4870637ce57d548d23c0b3330200014327c268.tar.xz puppet-9f4870637ce57d548d23c0b3330200014327c268.zip |
All rails *and* language tests now pass, with the exception of a language/resource test that passes by itself but fails when run as part of the whole suite. Also, I added deletion where appropriate, so that unspecified resources, parameters, and facts are now deleted, as one would expect.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1951 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/util/rails')
-rw-r--r-- | lib/puppet/util/rails/collection_merger.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/puppet/util/rails/collection_merger.rb b/lib/puppet/util/rails/collection_merger.rb new file mode 100644 index 000000000..7afd76f9c --- /dev/null +++ b/lib/puppet/util/rails/collection_merger.rb @@ -0,0 +1,25 @@ +module Puppet::Util::CollectionMerger + # Merge new values with the old list. This is only necessary + # because deletion seems to mess things up on unsaved objects. + def collection_merge(collection, list) + remove = send(collection).dup + + list.each do |value| + object = yield(value) + if remove.include?(object) + remove.delete(object) + end + end + + unless remove.empty? + # We have to save the current state else the deletion somehow deletes + # our new values. + save + remove.each do |r| + send(collection).delete(r) + end + end + end +end + +# $Id$ |