Class: Seahorse::Client::PluginList::PluginWrapper Private

Inherits:
Object
  • Object
show all
Defined in:
lib/seahorse/client/plugin_list.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A utility class that computes the canonical name for a plugin and defers requiring the plugin until the plugin class is required.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(plugin) ⇒ PluginWrapper

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of PluginWrapper

Parameters:

  • plugin (String, Symbol, Module, Class)


84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# 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

Instance Attribute Details

#canonical_nameString (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (String)


101
102
103
# File 'lib/seahorse/client/plugin_list.rb', line 101

def canonical_name
  @canonical_name
end

Class Method Details

.new(plugin) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the given plugin if it is already a PluginWrapper.



109
110
111
112
113
114
115
# File 'lib/seahorse/client/plugin_list.rb', line 109

def self.new(plugin)
  if plugin.is_a?(self)
    plugin
  else
    super
  end
end

Instance Method Details

#eql?(other) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


119
120
121
# File 'lib/seahorse/client/plugin_list.rb', line 119

def eql? other
  canonical_name == other.canonical_name
end

#hashString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (String)


125
126
127
# File 'lib/seahorse/client/plugin_list.rb', line 125

def hash
  canonical_name.hash
end

#pluginClass<Plugin>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:



104
105
106
# File 'lib/seahorse/client/plugin_list.rb', line 104

def plugin
  @plugin ||= require_plugin
end