diff options
author | Luke Kanies <luke@madstop.com> | 2009-06-01 17:50:55 -0500 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2009-06-03 07:33:33 +1000 |
commit | 650029e3730431dcc21863d92fd50c74665cea38 (patch) | |
tree | e0c4b77c10a6a199ffc8331b2ac29df731b4bd2a /lib/puppet/rails | |
parent | f1dba91bbde7919cb0a0fd412faacb1f7dd2c84d (diff) | |
download | puppet-650029e3730431dcc21863d92fd50c74665cea38.tar.gz puppet-650029e3730431dcc21863d92fd50c74665cea38.tar.xz puppet-650029e3730431dcc21863d92fd50c74665cea38.zip |
Always providing a value for 'exported' on Rails resources
We often didn't set a value, unless it was true, which
meant that if it had previously been true but was now
false, we didn't fix it.
We also were not always saving modified resources, which
in some cases resulted in work not getting saved.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib/puppet/rails')
-rw-r--r-- | lib/puppet/rails/resource.rb | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/puppet/rails/resource.rb b/lib/puppet/rails/resource.rb index 86a26ee39..758df64b1 100644 --- a/lib/puppet/rails/resource.rb +++ b/lib/puppet/rails/resource.rb @@ -26,7 +26,7 @@ class Puppet::Rails::Resource < ActiveRecord::Base # Determine the basic details on the resource. def self.rails_resource_initial_args(resource) - return [:type, :title, :line, :exported].inject({}) do |hash, param| + result = [:type, :title, :line].inject({}) do |hash, param| # 'type' isn't a valid column name, so we have to use another name. to = (param == :type) ? :restype : param if value = resource.send(param) @@ -34,6 +34,12 @@ class Puppet::Rails::Resource < ActiveRecord::Base end hash end + + # We always want a value here, regardless of what the resource has, + # so we break it out separately. + result[:exported] = resource.exported || false + + result end def add_resource_tag(tag) @@ -84,12 +90,15 @@ class Puppet::Rails::Resource < ActiveRecord::Base accumulate_benchmark("Individual resource merger", :attributes) { merge_attributes(resource) } accumulate_benchmark("Individual resource merger", :parameters) { merge_parameters(resource) } accumulate_benchmark("Individual resource merger", :tags) { merge_tags(resource) } + save() end def merge_attributes(resource) args = self.class.rails_resource_initial_args(resource) args.each do |param, value| - self[param] = value unless resource[param] == value + unless resource[param] == value + self[param] = value + end end # Handle file specially |