summaryrefslogtreecommitdiffstats
path: root/lib/puppet/rails
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/rails')
-rw-r--r--lib/puppet/rails/benchmark.rb2
-rw-r--r--lib/puppet/rails/host.rb9
-rw-r--r--lib/puppet/rails/resource.rb44
3 files changed, 22 insertions, 33 deletions
diff --git a/lib/puppet/rails/benchmark.rb b/lib/puppet/rails/benchmark.rb
index c33b2fb1e..1fbd011e9 100644
--- a/lib/puppet/rails/benchmark.rb
+++ b/lib/puppet/rails/benchmark.rb
@@ -64,6 +64,6 @@ module Puppet::Rails::Benchmark
data = {}
end
data[branch] = $benchmarks
- File.open(file, "w") { |f| f.print YAML.dump(data) }
+ Puppet::Util.secure_open(file, "w") { |f| f.print YAML.dump(data) }
end
end
diff --git a/lib/puppet/rails/host.rb b/lib/puppet/rails/host.rb
index d66fd2ed7..6b057dd2d 100644
--- a/lib/puppet/rails/host.rb
+++ b/lib/puppet/rails/host.rb
@@ -172,11 +172,6 @@ class Puppet::Rails::Host < ActiveRecord::Base
end
def find_resources_parameters_tags(resources)
- # initialize all resource parameters
- resources.each do |key,resource|
- resource.params_hash = []
- end
-
find_resources_parameters(resources)
find_resources_tags(resources)
end
@@ -294,7 +289,7 @@ class Puppet::Rails::Host < ActiveRecord::Base
# assign each loaded parameters/tags to the resource it belongs to
params.each do |param|
- resources[param['resource_id']].add_param_to_hash(param) if resources.include?(param['resource_id'])
+ resources[param['resource_id']].add_param_to_list(param) if resources.include?(param['resource_id'])
end
end
@@ -302,7 +297,7 @@ class Puppet::Rails::Host < ActiveRecord::Base
tags = Puppet::Rails::ResourceTag.find_all_tags_from_host(self)
tags.each do |tag|
- resources[tag['resource_id']].add_tag_to_hash(tag) if resources.include?(tag['resource_id'])
+ resources[tag['resource_id']].add_tag_to_list(tag) if resources.include?(tag['resource_id'])
end
end
diff --git a/lib/puppet/rails/resource.rb b/lib/puppet/rails/resource.rb
index 984bdc05a..7b37a52bf 100644
--- a/lib/puppet/rails/resource.rb
+++ b/lib/puppet/rails/resource.rb
@@ -63,22 +63,28 @@ class Puppet::Rails::Resource < ActiveRecord::Base
unserialize_value(self[:title])
end
- def add_param_to_hash(param)
- @params_hash ||= []
- @params_hash << param
+ def params_list
+ @params_list ||= []
end
- def add_tag_to_hash(tag)
- @tags_hash ||= []
- @tags_hash << tag
+ def params_list=(params)
+ @params_list = params
end
- def params_hash=(hash)
- @params_hash = hash
+ def add_param_to_list(param)
+ params_list << param
end
- def tags_hash=(hash)
- @tags_hash = hash
+ def tags_list
+ @tags_list ||= []
+ end
+
+ def tags_list=(tags)
+ @tags_list = tags
+ end
+
+ def add_tag_to_list(tag)
+ tags_list << tag
end
def [](param)
@@ -116,7 +122,7 @@ class Puppet::Rails::Resource < ActiveRecord::Base
db_params = {}
deletions = []
- @params_hash.each do |value|
+ params_list.each do |value|
# First remove any parameters our catalog resource doesn't have at all.
deletions << value['id'] and next unless catalog_params.include?(value['name'])
@@ -142,7 +148,7 @@ class Puppet::Rails::Resource < ActiveRecord::Base
# Lastly, add any new parameters.
catalog_params.each do |name, value|
- next if db_params.include?(name)
+ next if db_params.include?(name) && ! db_params[name].find{ |val| deletions.include?( val["id"] ) }
values = value.is_a?(Array) ? value : [value]
values.each do |v|
@@ -156,7 +162,7 @@ class Puppet::Rails::Resource < ActiveRecord::Base
in_db = []
deletions = []
resource_tags = resource.tags
- @tags_hash.each do |tag|
+ tags_list.each do |tag|
deletions << tag['id'] and next unless resource_tags.include?(tag['name'])
in_db << tag['name']
end
@@ -187,18 +193,6 @@ class Puppet::Rails::Resource < ActiveRecord::Base
end
end
- def parameters
- result = get_params_hash
- result.each do |param, value|
- if value.is_a?(Array)
- result[param] = value.collect { |v| v['value'] }
- else
- result[param] = value.value
- end
- end
- result
- end
-
def ref(dummy_argument=:work_arround_for_ruby_GC_bug)
"%s[%s]" % [self[:restype].split("::").collect { |s| s.capitalize }.join("::"), self.title.to_s]
end