diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-10-04 18:24:24 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-10-04 18:24:24 +0000 |
commit | 28cee40689440388994a4768bd301ae32c8ecc05 (patch) | |
tree | c865ab44f4c9247052cf83de16ffc8ebe8b15e54 /lib/puppet/rails/rails_resource.rb | |
parent | e0e291332bd4676962a28c7b220ae5c5e9651c0a (diff) | |
download | puppet-28cee40689440388994a4768bd301ae32c8ecc05.tar.gz puppet-28cee40689440388994a4768bd301ae32c8ecc05.tar.xz puppet-28cee40689440388994a4768bd301ae32c8ecc05.zip |
Merging the changes from the override-refactor branch. This is a significant rewrite of the parser, but it has little affect on the rest of the code tree.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1726 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/rails/rails_resource.rb')
-rw-r--r-- | lib/puppet/rails/rails_resource.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/puppet/rails/rails_resource.rb b/lib/puppet/rails/rails_resource.rb new file mode 100644 index 000000000..caad1b460 --- /dev/null +++ b/lib/puppet/rails/rails_resource.rb @@ -0,0 +1,34 @@ +require 'puppet' +require 'puppet/rails/rails_parameter' + +#RailsParameter = Puppet::Rails::RailsParameter +class Puppet::Rails::RailsResource < ActiveRecord::Base + has_many :rails_parameters, :dependent => :delete_all + serialize :tags, Array + + belongs_to :host + + # Convert our object to a resource. Do not retain whether the object + # is collectable, though, since that would cause it to get stripped + # from the configuration. + def to_resource(scope) + hash = self.attributes + hash["type"] = hash["restype"] + hash.delete("restype") + hash.delete("host_id") + hash.delete("id") + hash.each do |p, v| + hash.delete(p) if v.nil? + end + hash[:scope] = scope + hash[:source] = scope.source + obj = Puppet::Parser::Resource.new(hash) + rails_parameters.each do |param| + obj.set(param.to_resourceparam(scope.source)) + end + + return obj + end +end + +# $Id$ |