summaryrefslogtreecommitdiffstats
path: root/lib/puppet/rails/param_value.rb
blob: 02c29c5400efa547560d2b68ac1f02a54e1afacf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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