~nvalcarcel/ubuntu/lucid/puppet/fix-546677

« back to all changes in this revision

Viewing changes to lib/puppet/indirector/active_record.rb

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2009-12-23 00:48:10 UTC
  • mfrom: (1.1.10 upstream) (3.1.7 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091223004810-3i4oryds922g5n59
Tags: 0.25.1-3ubuntu1
* Merge from debian testing.  Remaining changes:
  - debian/rules:
    + Don't start puppet when first installing puppet.
  - debian/puppet.conf, lib/puppet/defaults.rb:
    + Move templates to /etc/puppet
  - lib/puppet/defaults.rb:
    + Fix /var/lib/puppet/state ownership.
  - man/man8/puppet.conf.8: 
    + Fix broken URL in manpage.
  - debian/control:
    + Update maintainer accordint to spec.
    + Puppetmaster Recommends -> Suggests
    + Created puppet-testsuite as a seperate. Allow the users to run puppet's 
      testsuite.
  - tests/Rakefile: Fix rakefile so that the testsuite can acutally be ran.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require 'puppet/indirector'
 
2
 
 
3
class Puppet::Indirector::ActiveRecord < Puppet::Indirector::Terminus
 
4
    class << self
 
5
        attr_accessor :ar_model
 
6
    end
 
7
 
 
8
    def self.use_ar_model(klass)
 
9
        self.ar_model = klass
 
10
    end
 
11
 
 
12
    def ar_model
 
13
        self.class.ar_model
 
14
    end
 
15
 
 
16
    def initialize
 
17
        Puppet::Rails.init
 
18
    end
 
19
 
 
20
    def find(request)
 
21
        return nil unless instance = ar_model.find_by_name(request.key)
 
22
        instance.to_puppet
 
23
    end
 
24
 
 
25
    def save(request)
 
26
        ar_model.from_puppet(request.instance).save
 
27
    end
 
28
end