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)


86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/seahorse/client/plugin_list.rb', line 86

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)


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

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.



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

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)


121
122
123
# File 'lib/seahorse/client/plugin_list.rb', line 121

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)


127
128
129
# File 'lib/seahorse/client/plugin_list.rb', line 127

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:



106
107
108
# File 'lib/seahorse/client/plugin_list.rb', line 106

def plugin
  @plugin ||= require_plugin
end