Module: Larynx::CallbacksWithAsync::ClassMethods

Defined in:
lib/larynx/callbacks_with_async.rb

Instance Method Summary collapse

Instance Method Details

#define_callback(*callbacks) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/larynx/callbacks_with_async.rb', line 16

def define_callback(*callbacks)
  options = callbacks.extract_options!
  callbacks.each do |callback|
    self.callback_options[callback] = options
    class_eval <<-DEF
      def #{callback}(mode=:sync, &block)
        @callbacks ||= {}
        @callbacks[:#{callback}] = [block, mode]
        self
      end
    DEF
  end
end