Class: Triggers
Defined Under Namespace
Classes: NonExistingTrigger
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #create(options) ⇒ Object
- #delete(*trigger_ids) ⇒ Object
-
#exists?(options) ⇒ Boolean
this is very unefficient but there is no other way to verify that a trigger exists..
- #get_id(options) ⇒ Object
Methods inherited from Base
Constructor Details
This class inherits a constructor from Base
Instance Method Details
#create(options) ⇒ Object
3 4 5 |
# File 'lib/zapix/proxies/triggers.rb', line 3 def create() client.trigger_create() unless exists?() end |
#delete(*trigger_ids) ⇒ Object
7 8 9 |
# File 'lib/zapix/proxies/triggers.rb', line 7 def delete(*trigger_ids) client.trigger_delete(trigger_ids) end |
#exists?(options) ⇒ Boolean
this is very unefficient but there is no other way to verify that a trigger exists..
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/zapix/proxies/triggers.rb', line 13 def exists?() result = client.trigger_get('output' => 'extend', 'expandExpression' => true) id = extract_id(result, ['expression']) if id.nil? false else true end end |
#get_id(options) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/zapix/proxies/triggers.rb', line 25 def get_id() result = client.trigger_get('output' => 'extend', 'expandExpression' => true) id = extract_id(result, ['expression']) if id.nil? raise NonExistingTrigger, "Trigger with expression #{['expression']} not found." else id end end |