diff --git a/Data/Scripts/006_Events and files/002_EventHandlers.rb b/Data/Scripts/006_Events and files/002_EventHandlers.rb index 32452638f..009f660bf 100644 --- a/Data/Scripts/006_Events and files/002_EventHandlers.rb +++ b/Data/Scripts/006_Events and files/002_EventHandlers.rb @@ -95,11 +95,14 @@ class HandlerHash return ret end - def addIf(condProc,handler) - @addIfs.push([condProc,handler]) + def addIf(conditionProc,handler=nil,&handlerBlock) + if ![Proc,Hash].include?(handler.class) && !block_given? + raise ArgumentError, "addIf call for #{self.class.name} has no valid handler (#{handler.inspect} was given)" + end + @addIfs.push([conditionProc,handler || handlerBlock]) end - def add(sym,handler=nil,&handlerBlock) # 'sym' can be an ID or symbol + def add(sym,handler=nil,&handlerBlock) # '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 (#{handler.inspect} was given)" end