lib/dry/plugins/registry.rb in dry-plugins-0.1.0 vs lib/dry/plugins/registry.rb in dry-plugins-0.2.0

- old
+ new

@@ -30,10 +30,14 @@ # @param key [#to_sym] # @param plugin [Module, Plugin] # # @return [Plugin] - def register(key, plugin) + def register(key, plugin = nil) + if key.is_a?(Module) + plugin = key + key = Inflecto.underscore(Inflecto.demodulize(plugin.name)) + end key = key.to_s plugin = plugin.plugin if plugin.is_a? Plugin if key?(key) && resolve(key) != plugin raise Registry::KeyError.new(self, key, plugin) end