mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
HandlerHash#add can now take a block
This commit is contained in:
@@ -99,11 +99,14 @@ class HandlerHash
|
|||||||
@addIfs.push([condProc,handler])
|
@addIfs.push([condProc,handler])
|
||||||
end
|
end
|
||||||
|
|
||||||
def add(sym,handler) # 'sym' can be an ID or symbol
|
def add(sym,handler=nil,&handler_block) # 'sym' can be an ID or symbol
|
||||||
|
if ![Proc,Hash].include?(handler.class) && !block_given?
|
||||||
|
raise ArgumentError, "#{self.class.name} for #{sym.inspect} has no valid handler"
|
||||||
|
end
|
||||||
id = fromSymbol(sym)
|
id = fromSymbol(sym)
|
||||||
@hash[id] = handler if id
|
@hash[id] = handler || handler_block if id
|
||||||
symbol = toSymbol(sym)
|
symbol = toSymbol(sym)
|
||||||
@hash[symbol] = handler if symbol
|
@hash[symbol] = handler || handler_block if symbol
|
||||||
end
|
end
|
||||||
|
|
||||||
def copy(src,*dests)
|
def copy(src,*dests)
|
||||||
|
|||||||
Reference in New Issue
Block a user