Class: Puppet::Indirector::ActiveRecord

Inherits:
Terminus show all
Defined in:
lib/vendor/puppet/indirector/active_record.rb

Constant Summary

Constants included from Util

Util::AbsolutePathPosix, Util::AbsolutePathWindows

Constants included from Util::Docs

Util::Docs::HEADER_LEVELS

Class Attribute Summary collapse

Attributes included from Util::Docs

#doc, #nodoc

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Terminus

abstract_terminus?, const2name, #indirection, indirection_name, inherited, mark_as_abstract_terminus, #model, model, #name, name2const, register_terminus_class, terminus_class, terminus_classes, #terminus_type

Methods included from Util::InstanceLoader

#instance_docs, #instance_hash, #instance_load, #instance_loader, #instance_loading?, #loaded_instance, #loaded_instances

Methods included from Util

absolute_path?, activerecord_version, benchmark, binread, chuser, classproxy, #execfail, #execpipe, execute, execute_posix, execute_windows, logmethods, memory, path_to_uri, proxy, replace_file, safe_posix_fork, symbolize, symbolizehash, symbolizehash!, synchronize_on, thinmark, #threadlock, uri_to_path, wait_for_output, which, withumask

Methods included from Util::POSIX

#get_posix_field, #gid, #idfield, #methodbyid, #methodbyname, #search_posix_field, #uid

Methods included from Util::Docs

#desc, #dochook, #doctable, #markdown_definitionlist, #markdown_header, #nodoc?, #pad, scrub

Constructor Details

#initializeActiveRecord

Returns a new instance of ActiveRecord.



16
17
18
# File 'lib/vendor/puppet/indirector/active_record.rb', line 16

def initialize
  Puppet::Rails.init
end

Class Attribute Details

.ar_modelObject

Returns the value of attribute ar_model.



5
6
7
# File 'lib/vendor/puppet/indirector/active_record.rb', line 5

def ar_model
  @ar_model
end

Class Method Details

.use_ar_model(klass) ⇒ Object



8
9
10
# File 'lib/vendor/puppet/indirector/active_record.rb', line 8

def self.use_ar_model(klass)
  self.ar_model = klass
end

Instance Method Details

#ar_modelObject



12
13
14
# File 'lib/vendor/puppet/indirector/active_record.rb', line 12

def ar_model
  self.class.ar_model
end

#find(request) ⇒ Object



20
21
22
23
# File 'lib/vendor/puppet/indirector/active_record.rb', line 20

def find(request)
  return nil unless instance = ar_model.find_by_name(request.key)
  instance.to_puppet
end

#save(request) ⇒ Object



25
26
27
# File 'lib/vendor/puppet/indirector/active_record.rb', line 25

def save(request)
  ar_model.from_puppet(request.instance).save
end