class Triggers
Public Instance Methods
create(options)
click to toggle source
# File lib/zapix/proxies/triggers.rb, line 3 def create(options) client.trigger_create(options) unless exists?(options) end
delete(*trigger_ids)
click to toggle source
# File lib/zapix/proxies/triggers.rb, line 7 def delete(*trigger_ids) client.trigger_delete(trigger_ids) end
exists?(options)
click to toggle source
this is very unefficient but there is no other way to verify that a trigger exists..
# File lib/zapix/proxies/triggers.rb, line 13 def exists?(options) result = client.trigger_get('output' => 'extend', 'expandExpression' => true) id = extract_id(result, options['expression']) if id.nil? false else true end end
get_id(options)
click to toggle source
# File lib/zapix/proxies/triggers.rb, line 25 def get_id(options) result = client.trigger_get('output' => 'extend', 'expandExpression' => true) id = extract_id(result, options['expression']) if id.nil? raise NonExistingTrigger, "Trigger with expression #{options['expression']} not found." else id end end
Private Instance Methods
extract_id(triggers, expression)
click to toggle source
# File lib/zapix/proxies/triggers.rb, line 40 def extract_id(triggers, expression) result = nil triggers.each do |trigger| if trigger['expression'] == expression result = trigger['triggerid'] break end end result end