diff options
| author | Luke Kanies <luke@madstop.com> | 2009-04-08 16:56:41 -0500 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2009-04-22 14:39:36 +1000 |
| commit | 6314745c054ba9482f145b4ec798431ac2f300a3 (patch) | |
| tree | 851f037a5aad8af01949ea8e9d82c369f1c9a2b6 /lib/puppet/util/rails | |
| parent | be30a618272d9828f90f5e726a23021be3b23221 (diff) | |
| download | puppet-6314745c054ba9482f145b4ec798431ac2f300a3.tar.gz puppet-6314745c054ba9482f145b4ec798431ac2f300a3.tar.xz puppet-6314745c054ba9482f145b4ec798431ac2f300a3.zip | |
Refactoring the Rails integration
This moves all code from the Parser class into
the ActiveRecord classes, and gets rid of
'ar_hash_merge'.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib/puppet/util/rails')
| -rw-r--r-- | lib/puppet/util/rails/collection_merger.rb | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/lib/puppet/util/rails/collection_merger.rb b/lib/puppet/util/rails/collection_merger.rb index 4a941b881..3a28bb304 100644 --- a/lib/puppet/util/rails/collection_merger.rb +++ b/lib/puppet/util/rails/collection_merger.rb @@ -1,43 +1,4 @@ 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, args) - remove = [] - list = args[:existing] || send(collection) - hash = args[:updates] - list.each do |object| - name = object.name - if existing = hash[name] - hash.delete(name) - if existing.respond_to?(:to_rails) - existing.to_rails(self, object) - elsif args.include?(:modify) - args[:modify].call(object, name, existing) - else - raise ArgumentError, "Must pass :modify or the new objects must respond to :to_rails" - end - else - remove << object - end - end - - # Make a new rails object for the rest of them - hash.each do |name, object| - if object.respond_to?(:to_rails) - object.to_rails(self) - elsif args.include?(:create) - args[:create].call(name, object) - else - raise ArgumentError, "Must pass :create or the new objects must respond to :to_rails" - end - end - - # Now remove anything necessary. - remove.each do |object| - send(collection).delete(object) - end - end - def ar_hash_merge(db_hash, mem_hash, args) (db_hash.keys | mem_hash.keys).each do |key| if (db_hash[key] && mem_hash[key]) |
