lib/ddplugin/registry.rb in ddplugin-1.0.1 vs lib/ddplugin/registry.rb in ddplugin-1.0.2
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
module DDPlugin
# The registry is responsible for keeping track of all loaded plugins.
class Registry
# Returns the shared {DDPlugin::Registry} instance, creating it if none
# exists yet.
@@ -23,11 +25,11 @@
#
# @param [Symbol] identifiers One or more symbols identifying the class
#
# @return [void]
def register(root_class, klass, *identifiers)
- identifiers.each do |identifier|
+ identifiers.map(&:to_sym).each do |identifier|
@classes_to_identifiers[root_class][klass] ||= []
@identifiers_to_classes[root_class][identifier] = klass
@classes_to_identifiers[root_class][klass] << identifier
end
@@ -51,9 +53,10 @@
#
# @param [Symbol] identifier The identifier of the class to return
#
# @return [Class, nil] The class with the given identifier
def find(root_class, identifier)
+ identifier = identifier.to_sym
@identifiers_to_classes[root_class] ||= {}
@identifiers_to_classes[root_class][identifier]
end
# Returns all classes that are registered descendants of the given class.