Class: Projects::TriggeredHooks

Inherits:
Object
  • Object
show all
Defined in:
app/models/projects/triggered_hooks.rb

Instance Method Summary collapse

Constructor Details

#initialize(scope, data) ⇒ TriggeredHooks

Returns a new instance of TriggeredHooks.


5
6
7
8
9
# File 'app/models/projects/triggered_hooks.rb', line 5

def initialize(scope, data)
  @scope = scope
  @data = data
  @relations = []
end

Instance Method Details

#add_hooks(relation) ⇒ Object


11
12
13
14
# File 'app/models/projects/triggered_hooks.rb', line 11

def add_hooks(relation)
  @relations << relation
  self
end

#executeObject


16
17
18
19
20
21
22
23
# File 'app/models/projects/triggered_hooks.rb', line 16

def execute
  # Assumes that the relations implement TriggerableHooks
  @relations.each do |hooks|
    hooks.hooks_for(@scope).select_active(@scope, @data).each do |hook|
      hook.async_execute(@data, @scope.to_s)
    end
  end
end