lib/jellyfish.rb in jellyfish-0.9.0 vs lib/jellyfish.rb in jellyfish-0.9.1
- old
+ new
@@ -221,10 +221,10 @@
handlers = self.class.handlers
if handlers.key?(e.class)
handlers[e.class]
else # or find the nearest match and cache it
ancestors = e.class.ancestors
- handlers[e.class] = handlers.
+ handlers[e.class] = handlers.dup. # thread safe iteration
inject([nil, Float::INFINITY]){ |(handler, val), (klass, block)|
idx = ancestors.index(klass) || Float::INFINITY # lower is better
if idx < val then [block, idx] else [handler, val] end }.first
end
end