summaryrefslogtreecommitdiffstats
path: root/lib/puppet/rails/resource.rb
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-06-14 17:41:42 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-06-14 17:41:42 +0000
commit45f76c5d0cb6473faf7dca656b90e299799edf94 (patch)
treec3585ae047c1b46fc45a1011549daa546b5290e7 /lib/puppet/rails/resource.rb
parente32a1bd40e6d706b4e0c5316bf32aec52133f309 (diff)
downloadpuppet-45f76c5d0cb6473faf7dca656b90e299799edf94.tar.gz
puppet-45f76c5d0cb6473faf7dca656b90e299799edf94.tar.xz
puppet-45f76c5d0cb6473faf7dca656b90e299799edf94.zip
Significantly optimizing the database queries -- I am getting about 40% better times now. See http://www.madstop.com/optimizing_the_activerecord_integration.html.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2585 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/rails/resource.rb')
-rw-r--r--lib/puppet/rails/resource.rb12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/puppet/rails/resource.rb b/lib/puppet/rails/resource.rb
index 0287a5a76..2f58681ab 100644
--- a/lib/puppet/rails/resource.rb
+++ b/lib/puppet/rails/resource.rb
@@ -16,7 +16,7 @@ class Puppet::Rails::Resource < ActiveRecord::Base
belongs_to :host
def add_resource_tag(tag)
- pt = Puppet::Rails::PuppetTag.find_or_create_by_name(tag)
+ pt = Puppet::Rails::PuppetTag.find_or_create_by_name(tag, :include => :puppet_tag)
resource_tags.create(:puppet_tag => pt)
end
@@ -33,16 +33,18 @@ class Puppet::Rails::Resource < ActiveRecord::Base
end
# returns a hash of param_names.name => [param_values]
- def get_params_hash
- return param_values.inject({}) do | hash, value |
+ def get_params_hash(values = nil)
+ values ||= param_values.find(:all, :include => :param_name)
+ return values.inject({}) do | hash, value |
hash[value.param_name.name] ||= []
hash[value.param_name.name] << value
hash
end
end
- def get_tag_hash
- return resource_tags.inject({}) do |hash, tag|
+ def get_tag_hash(tags = nil)
+ tags ||= resource_tags.find(:all, :include => :puppet_tag)
+ return tags.inject({}) do |hash, tag|
hash[tag.puppet_tag.name] = tag.puppet_tag.name
hash
end