diff options
Diffstat (limited to 'lib/puppet/parser/resource.rb')
-rw-r--r-- | lib/puppet/parser/resource.rb | 76 |
1 files changed, 32 insertions, 44 deletions
diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/resource.rb index 747338b3b..7dec02b1f 100644 --- a/lib/puppet/parser/resource.rb +++ b/lib/puppet/parser/resource.rb @@ -278,69 +278,57 @@ class Puppet::Parser::Resource return db_resource end - def to_s - self.ref - end - - # Translate our object to a transportable object. - def to_trans - return nil if virtual? + # Create a Puppet::Resource instance from this parser resource. + # We plan, at some point, on not needing to do this conversion, but + # it's sufficient for now. + def to_resource + result = Puppet::Resource.new(type, title) - if builtin? - to_transobject - else - to_transbucket - end - end - - def to_transbucket - bucket = Puppet::TransBucket.new([]) - - bucket.type = self.type - bucket.name = self.title - - # TransBuckets don't support parameters, which is why they're being deprecated. - return bucket - end - - # Convert this resource to a RAL resource. We hackishly go via the - # transportable stuff. - def to_type - to_trans.to_type - end - - def to_transobject - # Now convert to a transobject - obj = Puppet::TransObject.new(@ref.title, @ref.type) to_hash.each do |p, v| - if v.is_a?(Reference) - v = v.to_ref + if v.is_a?(Puppet::Parser::Resource::Reference) + v = Puppet::Resource::Reference.new(v.type, v.title) elsif v.is_a?(Array) - v = v.collect { |av| - if av.is_a?(Reference) - av = av.to_ref + v = v.collect do |av| + if av.is_a?(Puppet::Parser::Resource::Reference) + av = Puppet::Resource::Reference.new(av.type, av.title) end av - } + end end # If the value is an array with only one value, then # convert it to a single value. This is largely so that # the database interaction doesn't have to worry about # whether it returns an array or a string. - obj[p.to_s] = if v.is_a?(Array) and v.length == 1 + result[p] = if v.is_a?(Array) and v.length == 1 v[0] else v end end - obj.file = self.file - obj.line = self.line + result.file = self.file + result.line = self.line + result.tag(*self.tags) + + return result + end + + def to_s + self.ref + end + + # Translate our object to a transportable object. + def to_trans + return nil if virtual? - obj.tags = self.tags + return to_resource.to_trans + end - return obj + # Convert this resource to a RAL resource. We hackishly go via the + # transportable stuff. + def to_type + to_trans.to_type end private |