Module: Larynx::Callbacks::ClassMethods

Defined in:
lib/larynx/callbacks.rb

Instance Method Summary collapse

Instance Method Details

#define_callback(*callbacks) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/larynx/callbacks.rb', line 12

def define_callback(*callbacks)
  callbacks.each do |callback|
    class_eval <<-DEF
      def #{callback}(&block)
        @callbacks ||= {}
        @callbacks[:#{callback}] = block
        self
      end
    DEF
  end
end