summaryrefslogtreecommitdiffstats
path: root/lib/puppet/rails/resource.rb
diff options
context:
space:
mode:
authorshadoi <shadoi@980ebf18-57e1-0310-9a29-db15c13687c0>2007-02-15 20:26:40 +0000
committershadoi <shadoi@980ebf18-57e1-0310-9a29-db15c13687c0>2007-02-15 20:26:40 +0000
commit91991f186711251f20e1608815c49d360051c29a (patch)
tree0a0fab9db459b2d03f2dce89bcf15121d28a7b74 /lib/puppet/rails/resource.rb
parent0b5600a6b49400551b01cec7aa3286d42e45d36c (diff)
downloadpuppet-91991f186711251f20e1608815c49d360051c29a.tar.gz
puppet-91991f186711251f20e1608815c49d360051c29a.tar.xz
puppet-91991f186711251f20e1608815c49d360051c29a.zip
Merge fact_names & fact_values, and param_names & param_values.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2191 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/rails/resource.rb')
-rw-r--r--lib/puppet/rails/resource.rb27
1 files changed, 13 insertions, 14 deletions
diff --git a/lib/puppet/rails/resource.rb b/lib/puppet/rails/resource.rb
index 6656c2450..b0bfc1ed6 100644
--- a/lib/puppet/rails/resource.rb
+++ b/lib/puppet/rails/resource.rb
@@ -1,17 +1,21 @@
require 'puppet'
require 'puppet/rails/external/tagging/init'
-require 'puppet/rails/param_name'
+require 'puppet/rails/param'
require 'puppet/util/rails/collection_merger'
class Puppet::Rails::Resource < ActiveRecord::Base
include Puppet::Util::CollectionMerger
- has_many :param_values, :through => :param_names
- has_many :param_names, :dependent => :destroy
+ has_many :params, :dependent => :destroy
belongs_to :source_file
belongs_to :host
acts_as_taggable
+
+ Puppet::Type.eachtype do |type|
+ klass = Class.new(Puppet::Rails::Resource)
+ Object.const_set("Puppet%s" % type.name.to_s.capitalize, klass)
+ end
def tags=(tags)
tags.each do |tag|
@@ -28,20 +32,15 @@ class Puppet::Rails::Resource < ActiveRecord::Base
end
def parameter(param)
- if pn = param_names.find_by_name(param)
- if pv = pn.param_values.find(:first)
- return pv.value
- else
- return nil
- end
+ if p = params.find_by_name(param)
+ return p.value
end
end
def parameters
hash = {}
- self.param_values.find(:all).each do |pvalue|
- pname = pvalue.param_name.name
- hash.store(pname, pvalue.value)
+ self.params.find(:all).each do |p|
+ hash.store(p.name, p.value)
end
return hash
end
@@ -70,8 +69,8 @@ class Puppet::Rails::Resource < ActiveRecord::Base
hash[:scope] = scope
hash[:source] = scope.source
obj = Puppet::Parser::Resource.new(hash)
- self.param_names.each do |pname|
- obj.set(pname.to_resourceparam(scope.source))
+ self.params.each do |p|
+ obj.set(p.to_resourceparam(scope.source))
end
# Store the ID, so we can check if we're re-collecting the same resource.