mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-07 13:15:01 +00:00
Resolving clashing code from merge
This commit is contained in:
@@ -96,15 +96,11 @@ end
|
|||||||
#===============================================================================
|
#===============================================================================
|
||||||
class HandlerHash
|
class HandlerHash
|
||||||
def initialize
|
def initialize
|
||||||
@hash = {}
|
@hash = {}
|
||||||
@add_ifs = []
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def [](id)
|
def [](id)
|
||||||
return @hash[id] if id && @hash[id]
|
return @hash[id] if id && @hash[id]
|
||||||
@add_ifs.each do |add_if|
|
|
||||||
return add_if[2] if add_if[1].call(id)
|
|
||||||
end
|
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -115,13 +111,6 @@ class HandlerHash
|
|||||||
@hash[id] = handler || handlerBlock if id && !id.empty?
|
@hash[id] = handler || handlerBlock if id && !id.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_if(id, conditionProc, handler = nil, &handlerBlock)
|
|
||||||
if ![Proc, Hash].include?(handler.class) && !block_given?
|
|
||||||
raise ArgumentError, "add_if call for #{self.class.name} has no valid handler (#{handler.inspect} was given)"
|
|
||||||
end
|
|
||||||
@add_ifs.push([id, conditionProc, handler || handlerBlock])
|
|
||||||
end
|
|
||||||
|
|
||||||
def copy(src, *dests)
|
def copy(src, *dests)
|
||||||
handler = self[src]
|
handler = self[src]
|
||||||
return if !handler
|
return if !handler
|
||||||
@@ -129,16 +118,11 @@ class HandlerHash
|
|||||||
end
|
end
|
||||||
|
|
||||||
def remove(key)
|
def remove(key)
|
||||||
if @hash.keys.include?(key)
|
@hash.delete(key)
|
||||||
@hash.delete(key)
|
|
||||||
else
|
|
||||||
@add_ifs.delete_if { |add_if| add_if[0] == key }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def clear
|
def clear
|
||||||
@hash.clear
|
@hash.clear
|
||||||
@add_ifs.clear
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def each
|
def each
|
||||||
@@ -158,7 +142,8 @@ end
|
|||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# A stripped-down version of class HandlerHash which only deals with IDs that
|
# A stripped-down version of class HandlerHash which only deals with IDs that
|
||||||
# are symbols.
|
# are symbols. Also contains an add_ifs hash for code that applies to multiple
|
||||||
|
# IDs (determined by its condition proc).
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
class HandlerHashSymbol
|
class HandlerHashSymbol
|
||||||
def initialize
|
def initialize
|
||||||
@@ -271,6 +256,13 @@ class HandlerHashEnum
|
|||||||
@hash[symbol] = handler || handlerBlock if symbol
|
@hash[symbol] = handler || handlerBlock if symbol
|
||||||
end
|
end
|
||||||
|
|
||||||
|
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 copy(src, *dests)
|
def copy(src, *dests)
|
||||||
handler = self[src]
|
handler = self[src]
|
||||||
return if !handler
|
return if !handler
|
||||||
|
|||||||
Reference in New Issue
Block a user