Class: Iord::HookSet

Inherits:
Object
  • Object
show all
Defined in:
lib/iord/hooks.rb

Class Method Summary collapse

Class Method Details

.execute_hook(name, action, resource) ⇒ Object



61
62
63
64
65
66
67
68
69
# File 'lib/iord/hooks.rb', line 61

def self.execute_hook(name, action, resource)
  name = name.to_sym
  action = action.to_sym
  if hooks[name] and hooks[name][action]
    hooks[name][action].each do |hook|
      hook.call(resource, action)
    end
  end
end

.register_hook(name, action, hook) ⇒ Object



53
54
55
56
57
58
59
# File 'lib/iord/hooks.rb', line 53

def self.register_hook(name, action, hook)
  name = name.to_sym
  action = action.to_sym
  hooks[name] ||= Hash.new
  hooks[name][action] ||= Array.new
  hooks[name][action] << hook
end