Class: Rubix::Script

Inherits:
Model
  • Object
show all
Defined in:
lib/rubix/models/script.rb

Constant Summary collapse

ACCESS_CODES =

Numeric codes of the access types a script can require to run on a host.

Default is ‘read’.

{
  :read  => 2,
  :write => 3
}.freeze
ACCESS_NAMES =
ACCESS_CODES.invert.freeze

Instance Attribute Summary

Attributes inherited from Model

#id, #properties

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Model

#after_create, all, all_params, all_request, #before_destroy, #before_update, #create, #create_request, #destroy, #destroy_params, #destroy_request, each, find, find_or_create, find_request, get_params, id_field, #id_field, #initialize, list, #new_record?, properties, #request, request, #resource_name, resource_name, #save, #to_hash, #update, #update_params, #update_request, #validate, web_request, zabbix_attr, zabbix_name

Methods included from Logs

#debug, #error, #fatal, #info, #warn

Constructor Details

This class inherits a constructor from Rubix::Model

Class Method Details

.build(script) ⇒ Object



39
40
41
42
43
44
45
46
# File 'lib/rubix/models/script.rb', line 39

def self.build script
  new({
        :id          => script[id_field].to_i,
        :name        => script['name'],
        :command     => script['command'],
        :access      => self::ACCESS_NAMES[script['host_access'].to_i]
      })
end

.find_params(options = {}) ⇒ Object



35
36
37
# File 'lib/rubix/models/script.rb', line 35

def self.find_params options={}
  get_params.merge(:filter => {id_field => options[:id], :name => options[:name]})
end

Instance Method Details

#create_paramsObject

Requests ==



27
28
29
30
31
32
33
# File 'lib/rubix/models/script.rb', line 27

def create_params
  {
    :name        => name,
    :command     => command,
    :host_access => self.class::ACCESS_CODES[access]
  }
end