Class: Easyhooks::Trigger

Inherits:
Base
  • Object
show all
Defined in:
lib/easyhooks/trigger.rb

Constant Summary

Constants included from Validators

Validators::ALLOWED_METHODS, Validators::ALLOWED_ON_VALUES, Validators::ALLOWED_TYPES

Instance Attribute Summary collapse

Attributes inherited from Base

#condition, #hook, #name, #on_fail, #payload, #type

Instance Method Summary collapse

Constructor Details

#initialize(name, hook, args = {}) ⇒ Trigger

Returns a new instance of Trigger.



10
11
12
13
14
15
16
# File 'lib/easyhooks/trigger.rb', line 10

def initialize(name, hook, args = {})
  super(name, args[:type], hook, args[:if], args[:payload], args[:on_fail])
  @args = args
  @on = validate_on(args[:on])
  @only = validate_only(args[:only])
  @actions = []
end

Instance Attribute Details

#actionsObject

Returns the value of attribute actions.



8
9
10
# File 'lib/easyhooks/trigger.rb', line 8

def actions
  @actions
end

#argsObject

Returns the value of attribute args.



8
9
10
# File 'lib/easyhooks/trigger.rb', line 8

def args
  @args
end

#onObject

Returns the value of attribute on.



8
9
10
# File 'lib/easyhooks/trigger.rb', line 8

def on
  @on
end

#onlyObject

Returns the value of attribute only.



8
9
10
# File 'lib/easyhooks/trigger.rb', line 8

def only
  @only
end

Instance Method Details

#add_action(action) ⇒ Object



18
19
20
# File 'lib/easyhooks/trigger.rb', line 18

def add_action(action)
  @actions.push(action)
end