diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-05-13 04:52:34 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-05-13 04:52:34 +0000 |
commit | 5863a0336e1f3bd5e1be85676bb0e7ac7337f2e6 (patch) | |
tree | 7d6cadbf16f19cab8d3c89db3a4b95161241c88b /lib/puppet/rails/rails_object.rb | |
parent | 0819e35be74bc997c3a953f05bab874b8d76429d (diff) | |
download | puppet-5863a0336e1f3bd5e1be85676bb0e7ac7337f2e6.tar.gz puppet-5863a0336e1f3bd5e1be85676bb0e7ac7337f2e6.tar.xz puppet-5863a0336e1f3bd5e1be85676bb0e7ac7337f2e6.zip |
Adding initial rails support. One can now store host configurations using ActiveRecord into a database (I have only tested sqlite3). Tomorrow will be the grammars used to retrieve those records for object collection.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1187 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/rails/rails_object.rb')
-rw-r--r-- | lib/puppet/rails/rails_object.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/puppet/rails/rails_object.rb b/lib/puppet/rails/rails_object.rb new file mode 100644 index 000000000..819706957 --- /dev/null +++ b/lib/puppet/rails/rails_object.rb @@ -0,0 +1,40 @@ +require 'puppet' +require 'puppet/rails/rails_parameter' + +RailsParameter = Puppet::Rails::RailsParameter +class Puppet::Rails::RailsObject < ActiveRecord::Base + has_many :rails_parameters, :dependent => :delete_all + serialize :tags, Array + + belongs_to :host + + # Add a set of parameters. + def addparams(params) + params.each do |pname, pvalue| + pobj = RailsParameter.new( + :name => pname, + :value => pvalue + ) + + self.rails_parameters << pobj + end + end + + # Convert our object to a trans_object + def to_trans + obj = Puppet::TransObject.new(name(), ptype()) + + [:file, :line, :tags].each do |method| + if val = send(method) + obj.send(method.to_s + "=", val) + end + end + params.each do |name, value| + obj[name] = value + end + + return obj + end +end + +# $Id$ |