class Seahorse::Client::PluginList::PluginWrapper
A utility class that computes the canonical name for a plugin and defers requiring the plugin until the plugin class is required. @api private
Attributes
canonical_name[R]
@return [String]
Public Class Methods
new(plugin)
click to toggle source
@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 @canonical_name, @gem_name = plugin.to_s.split('.').reverse @plugin = nil else @canonical_name = plugin.object_id @plugin = plugin end end
new(plugin)
click to toggle source
Returns the given plugin if it is already a PluginWrapper.
Calls superclass method
# File lib/seahorse/client/plugin_list.rb, line 107 def self.new(plugin) if plugin.is_a?(self) plugin else super end end
Public Instance Methods
eql?(other)
click to toggle source
@return [Boolean] @api private
# File lib/seahorse/client/plugin_list.rb, line 117 def eql? other canonical_name == other.canonical_name end
hash()
click to toggle source
@return [String] @api private
# File lib/seahorse/client/plugin_list.rb, line 123 def hash canonical_name.hash end
plugin()
click to toggle source
@return [Class<Plugin>]
# File lib/seahorse/client/plugin_list.rb, line 102 def plugin @plugin ||= require_plugin end
Private Instance Methods
require_plugin()
click to toggle source
@return [Class<Plugin>]
# File lib/seahorse/client/plugin_list.rb, line 130 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