Module: Chrysalis::Hookable

Included in:
Chrysalis
Defined in:
lib/chrysalis/loader.rb

Constant Summary collapse

@@handlers =
[]

Instance Method Summary collapse

Instance Method Details

#hook(evt, proc) ⇒ Object



135
136
137
# File 'lib/chrysalis/loader.rb', line 135

def hook(evt, proc)
  @@handlers << [evt, proc]
end

#post(evt, *args) ⇒ Object



139
140
141
142
143
144
# File 'lib/chrysalis/loader.rb', line 139

def post(evt, *args)
  callbacks = @@handlers.select { |e, ignore| evt == e }
  callbacks.each do |ignore, proc|
    proc.call(*args)
  end
end