lib/nanoc/base/plugin_registry.rb in nanoc-3.6.7 vs lib/nanoc/base/plugin_registry.rb in nanoc-3.6.8

- old
+ new

@@ -26,11 +26,11 @@ # @overload identifiers # # @return [Array<Symbol>] The identifiers for this plugin def identifiers(*identifiers) if identifiers.empty? - Nanoc::PluginRegistry.instance.identifiers_of(self.superclass, self) + Nanoc::PluginRegistry.instance.identifiers_of(superclass, self) else register(self, *identifiers) end end @@ -43,15 +43,15 @@ # @return [void] # # @overload identifier # # @return [Symbol] The first identifier for this plugin - def identifier(identifier=nil) + def identifier(identifier = nil) if identifier - self.identifiers(identifier) + identifiers(identifier) else - Nanoc::PluginRegistry.instance.identifiers_of(self.superclass, self).first + Nanoc::PluginRegistry.instance.identifiers_of(superclass, self).first end end # Registers the given class as a plugin with the given identifier. # @@ -92,11 +92,11 @@ # Returns the shared {PluginRegistry} instance, creating it if none exists # yet. # # @return [Nanoc::PluginRegistry] The shared plugin registry def self.instance - @instance ||= self.new + @instance ||= new end # Creates a new plugin registry. This should usually not be necessary; it # is recommended to use the shared instance (obtained from # {Nanoc::PluginRegistry.instance}). @@ -158,11 +158,11 @@ # # @return [Enumerable<Class>] A collection of class plugins def find_all(klass) @identifiers_to_classes[klass] ||= {} res = {} - @identifiers_to_classes[klass].each_pair { |k,v| res[k] = resolve(v, k) } + @identifiers_to_classes[klass].each_pair { |k, v| res[k] = resolve(v, k) } res end # Returns a list of all plugins. The returned list of plugins is an array # with array elements in the following format: @@ -204,10 +204,10 @@ protected def resolve(class_or_name, klass) if class_or_name.is_a?(String) - class_or_name.scan(/\w+/).inject(Kernel) do |memo, part| + class_or_name.scan(/\w+/).reduce(Kernel) do |memo, part| memo.const_get(part) end else class_or_name end