A utility class that computes the canonical name for a plugin and defers requiring the plugin until the plugin class is required. @api private
@return [String]
@param [String, Symbol, Module, Class] plugin
# File lib/seahorse/client/plugin_list.rb, line 84 def initialize(plugin) case plugin when Module @canonical_name = plugin.name || plugin.object_id @plugin = plugin when Symbol, String words = plugin.to_s.split('.') @canonical_name = words.pop @gem_name = words.empty? ? nil : words.join('.') @plugin = nil else @canonical_name = plugin.object_id @plugin = plugin end end
Returns the given plugin if it is already a PluginWrapper.
# File lib/seahorse/client/plugin_list.rb, line 109 def self.new(plugin) if plugin.is_a?(self) plugin else super end end
@return [Boolean] @api private
# File lib/seahorse/client/plugin_list.rb, line 119 def eql? other canonical_name == other.canonical_name end
@return [String] @api private
# File lib/seahorse/client/plugin_list.rb, line 125 def hash canonical_name.hash end
@return [Class<Plugin>]
# File lib/seahorse/client/plugin_list.rb, line 104 def plugin @plugin ||= require_plugin end
@return [Class<Plugin>]
# File lib/seahorse/client/plugin_list.rb, line 132 def require_plugin require(@gem_name) if @gem_name plugin_class = Kernel @canonical_name.split('::').each do |const_name| plugin_class = plugin_class.const_get(const_name) end plugin_class end