lib/industrialist/factory.rb in industrialist-0.2.1 vs lib/industrialist/factory.rb in industrialist-0.3.0

- old
+ new

@@ -5,14 +5,18 @@ def initialize @registry = {} end def register(key, klass) - registry[key&.to_sym] = klass + registry[factory_key(key)] = klass end - def build(event_type, *args) - klass = registry[event_type&.to_sym] + def build(key, *args) + klass = registry[factory_key(key)] klass&.new(*args) + end + + def factory_key(key) + (key.respond_to?(:to_sym) && key.to_sym) || key end end end