Class: Rubix::Script

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

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_define, 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



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

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



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

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

Instance Method Details

#create_paramsObject

Requests ==



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

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