# class Facts::ActiveRecord

### Public Class Methods

new() click to toggle source
Calls superclass method Puppet::Indirector::ActiveRecord.new

    # File lib/puppet/indirector/facts/active_record.rb, line 12
    def initialize
      Puppet.deprecation_warning "ActiveRecord-based storeconfigs and inventory are deprecated. See http://links.puppetlabs.com/activerecord-deprecation"
      super
    end

### Public Instance Methods

find(request) click to toggle source

Find the Rails host and pull its facts as a Facts instance.

    # File lib/puppet/indirector/facts/active_record.rb, line 18
    def find(request)
      return nil unless host = ar_model.find_by_name(request.key, :include => {:fact_values => :fact_name})

      facts = Puppet::Node::Facts.new(host.name)
      facts.values = host.get_facts_hash.inject({}) do |hash, ary|
        # Convert all single-member arrays into plain values.
        param = ary[0]
        values = ary[1].collect { |v| v.value }
        values = values[0] if values.length == 1
        hash[param] = values
        hash
      end

      facts
    end

save(request) click to toggle source

Save the values from a Facts instance as the facts on a Rails Host instance.

    # File lib/puppet/indirector/facts/active_record.rb, line 35
    def save(request)
      facts = request.instance

      host = ar_model.find_by_name(facts.name) || ar_model.create(:name => facts.name)

      host.merge_facts(facts.values)

      host.save
    end