summaryrefslogtreecommitdiffstats
path: root/lib/puppet/rails
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-07-18 19:47:09 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-07-18 19:47:09 +0000
commitf59ce4ee06ac734362a8fced4523b657ed4adef3 (patch)
tree23258bbc0046d78452d32a6ab7d69e3710edbd5c /lib/puppet/rails
parent53a469c0000eb1f487eab456c0986d427d714bd7 (diff)
downloadpuppet-f59ce4ee06ac734362a8fced4523b657ed4adef3.tar.gz
puppet-f59ce4ee06ac734362a8fced4523b657ed4adef3.tar.xz
puppet-f59ce4ee06ac734362a8fced4523b657ed4adef3.zip
Fixing #695 -- resource references will correctly serialize and unserialize in the db
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2706 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/rails')
-rw-r--r--lib/puppet/rails/param_name.rb3
-rw-r--r--lib/puppet/rails/param_value.rb19
2 files changed, 20 insertions, 2 deletions
diff --git a/lib/puppet/rails/param_name.rb b/lib/puppet/rails/param_name.rb
index 1f633638e..d704693c4 100644
--- a/lib/puppet/rails/param_name.rb
+++ b/lib/puppet/rails/param_name.rb
@@ -12,8 +12,7 @@ class Puppet::Rails::ParamName < ActiveRecord::Base
hash[:value] = resource.param_values.find(:all, :conditions => [ "param_name_id = ?", self]).collect { |v| v.value }
if hash[:value].length == 1
hash[:value] = hash[:value].shift
- end
- if hash[:value].empty?
+ elsif hash[:value].empty?
hash[:value] = nil
end
Puppet::Parser::Resource::Param.new hash
diff --git a/lib/puppet/rails/param_value.rb b/lib/puppet/rails/param_value.rb
index f463608a6..a176413eb 100644
--- a/lib/puppet/rails/param_value.rb
+++ b/lib/puppet/rails/param_value.rb
@@ -1,6 +1,25 @@
class Puppet::Rails::ParamValue < ActiveRecord::Base
belongs_to :param_name
belongs_to :resource
+
+ def value
+ val = self[:value]
+ if val =~ /^--- \!/
+ YAML.load(val)
+ else
+ val
+ end
+ end
+
+ # I could not find a cleaner way to handle making sure that resource references
+ # were consistently serialized and deserialized.
+ def value=(val)
+ if val.is_a?(Puppet::Parser::Resource::Reference)
+ self[:value] = YAML.dump(val)
+ else
+ self[:value] = val
+ end
+ end
end
# $Id$