Class: Yack::Handler

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

Instance Method Summary collapse

Constructor Details

#initialize(method, callbacks) ⇒ Handler

Returns a new instance of Handler.



32
33
34
35
# File 'lib/yack.rb', line 32

def initialize method, callbacks
  callbacks[method] ||= {}
  @callbacks = callbacks[method]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object



37
38
39
40
41
42
43
44
45
# File 'lib/yack.rb', line 37

def method_missing m, *args, &block
  if block_given?
    @callbacks[m] = block
  else
    @callbacks[m] ||= {}
    @callbacks = @callbacks[m]
    return self
  end
end