summaryrefslogtreecommitdiffstats
path: root/lib/puppet/rails/resource.rb
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-04-08 17:45:24 -0500
committerJames Turnbull <james@lovedthanlost.net>2009-04-22 14:39:36 +1000
commitea4e3b286bd66e925c3ae5853a3a43fc5b30175f (patch)
treeffb57bc645f4cae2b405bea189846a8778f45221 /lib/puppet/rails/resource.rb
parent6314745c054ba9482f145b4ec798431ac2f300a3 (diff)
downloadpuppet-ea4e3b286bd66e925c3ae5853a3a43fc5b30175f.tar.gz
puppet-ea4e3b286bd66e925c3ae5853a3a43fc5b30175f.tar.xz
puppet-ea4e3b286bd66e925c3ae5853a3a43fc5b30175f.zip
Adding more time debugging to Rails code, and refactoring a bit
There is an accumulation in the resource tags (hackish enough but soon to be replaced), and I've fixed a small bug in the tags merging that was causing lots of extra work (like 3x). Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib/puppet/rails/resource.rb')
-rw-r--r--lib/puppet/rails/resource.rb30
1 files changed, 9 insertions, 21 deletions
diff --git a/lib/puppet/rails/resource.rb b/lib/puppet/rails/resource.rb
index 27bf96783..0c8c9aa52 100644
--- a/lib/puppet/rails/resource.rb
+++ b/lib/puppet/rails/resource.rb
@@ -17,24 +17,9 @@ class Puppet::Rails::Resource < ActiveRecord::Base
belongs_to :source_file
belongs_to :host
- # Turn a parser resource into a Rails resource.
- def self.from_parser_resource(resource)
- args = rails_resource_initial_args(resource)
-
- db_resource = create(args)
-
- # Our file= method does the name to id conversion.
- db_resource.file = resource.file
-
- resource.eachparam do |param|
- Puppet::Rails::ParamValue.from_parser_param(param).each do |value_hash|
- db_resource.param_values.build(value_hash)
- end
- end
-
- resource.tags.each { |tag| db_resource.add_resource_tag(tag) }
-
- return db_resource
+ @tags = {}
+ def self.tags
+ @tags
end
# Determine the basic details on the resource.
@@ -94,9 +79,12 @@ class Puppet::Rails::Resource < ActiveRecord::Base
# Make sure this resource is equivalent to the provided Parser resource.
def merge_parser_resource(resource)
- merge_attributes(resource)
- merge_parameters(resource)
- merge_tags(resource)
+ times = {}
+ times[:attributes] = Benchmark.realtime { merge_attributes(resource) }
+ times[:parameters] = Benchmark.realtime { merge_parameters(resource) }
+ times[:tags] = Benchmark.realtime { merge_tags(resource) }
+
+ times
end
def merge_attributes(resource)