Module: EagleClaw::Callbacks
- Included in:
- Scraper
- Defined in:
- lib/eagleclaw/callbacks.rb
Instance Method Summary collapse
-
#register(context, meth = nil, &block) ⇒ Object
Register a callback for a given context.
-
#run_callbacks(context, recipient = self) ⇒ nil
Run the callbacks for a given context.
Instance Method Details
#register(context, : method_name) ⇒ Object #register(context, &block) ⇒ Object
Register a callback for a given context.
36 37 38 39 |
# File 'lib/eagleclaw/callbacks.rb', line 36 def register(context, meth = nil, &block) callback = block_given? ? block : meth ((@callbacks ||= {})[context] ||= []) << callback end |
#run_callbacks(context, recipient = self) ⇒ nil
Run the callbacks for a given context.
47 48 49 50 |
# File 'lib/eagleclaw/callbacks.rb', line 47 def run_callbacks(context, recipient = self) (@callbacks[context] || []).each { |callback| run_proc(callback, recipient) } nil end |