Class: Yack::Callback

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

Instance Method Summary collapse

Constructor Details

#initializeCallback

Returns a new instance of Callback.



3
4
5
# File 'lib/yack.rb', line 3

def initialize
  @callbacks = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



13
14
15
# File 'lib/yack.rb', line 13

def method_missing m, *args, &block
  block_given? ? @callbacks[m] = block : Handler.new(m, @callbacks)
end

Instance Method Details

#process(hash) ⇒ Object



7
8
9
10
11
# File 'lib/yack.rb', line 7

def process hash
  @callbacks.keys.each{|key|
    _call_back @callbacks[key], hash[key]
  }
end