Class: Rubix::Condition
Constant Summary collapse
- JOIN_CODES =
Numeric codes for the operator to use to join conditions for this action. Default is ‘and_or’.
{ :and_or => 0, :and => 1, :or => 2 }.freeze
- JOIN_NAMES =
JOIN_CODES.invert.freeze
- TYPE_CODES =
Numeric codes for the event source.
{ :host_group => 0, :host => 1, :trigger => 2, :trigger_name => 3, :trigger_severity => 4, :trigger_value => 5, :time_period => 6, :dhost_ip => 7, :dservice_type => 8, :dservice_port => 9, :dstatus => 10, :duptime => 11, :dvalue => 12, :host_template => 13, :event_acknowledged => 14, :application => 15, :maintenance => 16, :node => 17, :drule => 18, :dcheck => 19, :proxy => 20, :dobject => 21, :host_name => 22 }.freeze
- TYPE_NAMES =
TYPE_CODES.invert.freeze
- OPERATOR_CODES =
Numeric codes for the operator used to compare a condition’s type to its value.
{ :equal => 0, :not_equal => 1, :like => 2, :not_like => 3, :in => 4, :gte => 5, :lte => 6, :not_in => 7, }.freeze
- OPERATOR_NAMES =
OPERATOR_CODES.invert.freeze
Instance Attribute Summary
Attributes inherited from Model
Class Method Summary collapse
Instance Method Summary collapse
-
#create_params ⇒ Object
Requests ==.
-
#initialize(properties = nil) ⇒ Condition
constructor
A new instance of Condition.
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_params, find_request, get_params, id_field, #id_field, 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
#initialize(properties = nil) ⇒ Condition
Returns a new instance of Condition.
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/rubix/models/condition.rb', line 64 def initialize properties=nil if properties.is_a?(Array) raise ArgumentError.new("Must provide a condition type, operator, and value when initializing a condition with an array.") unless properties.size == 3 super({ :type => properties[0], :operator => properties[1], :value => properties[2] }) else super(properties || {}) end end |
Class Method Details
.build(condition) ⇒ Object
89 90 91 92 93 94 95 96 |
# File 'lib/rubix/models/condition.rb', line 89 def self.build condition new({ :id => condition[id_field].to_i, :type => self::TYPE_NAMES[condition['conditiontype'].to_i], :operator => self::OPERATOR_NAMES[condition['operator'].to_i], :value => condition['value'].to_s }) end |
Instance Method Details
#create_params ⇒ Object
Requests ==
81 82 83 84 85 86 87 |
# File 'lib/rubix/models/condition.rb', line 81 def create_params { :conditiontype => self.class::TYPE_CODES[type], :operator => self.class::OPERATOR_CODES[operator], :value => value.to_s } end |