Class: Seahorse::Client::PluginList
- Inherits:
-
Object
- Object
- Seahorse::Client::PluginList
- Includes:
- Enumerable
- Defined in:
- lib/seahorse/client/plugin_list.rb
Defined Under Namespace
Classes: PluginWrapper
Instance Method Summary collapse
-
#add(plugin) ⇒ void
Adds and returns the ‘plugin`.
-
#each(&block) ⇒ Enumerator
Enumerates the plugins.
-
#initialize(plugins = [], options = {}) ⇒ PluginList
constructor
A new instance of PluginList.
-
#remove(plugin) ⇒ void
Removes and returns the ‘plugin`.
-
#set(plugins) ⇒ void
Replaces the existing list of plugins.
Constructor Details
#initialize(plugins = [], options = {}) ⇒ PluginList
Returns a new instance of PluginList.
12 13 14 15 16 17 18 19 20 |
# File 'lib/seahorse/client/plugin_list.rb', line 12 def initialize(plugins = [], = {}) @mutex = [:mutex] || Mutex.new @plugins = Set.new if plugins.is_a?(PluginList) plugins.send(:each_plugin) { |plugin| _add(plugin) } else plugins.each { |plugin| _add(plugin) } end end |
Instance Method Details
#add(plugin) ⇒ void
This method returns an undefined value.
Adds and returns the ‘plugin`.
25 26 27 28 29 30 |
# File 'lib/seahorse/client/plugin_list.rb', line 25 def add(plugin) @mutex.synchronize do _add(plugin) end nil end |
#each(&block) ⇒ Enumerator
Enumerates the plugins.
57 58 59 60 61 |
# File 'lib/seahorse/client/plugin_list.rb', line 57 def each(&block) each_plugin do |plugin_wrapper| yield(plugin_wrapper.plugin) end end |
#remove(plugin) ⇒ void
This method returns an undefined value.
Removes and returns the ‘plugin`.
35 36 37 38 39 40 |
# File 'lib/seahorse/client/plugin_list.rb', line 35 def remove(plugin) @mutex.synchronize do @plugins.delete(PluginWrapper.new(plugin)) end nil end |
#set(plugins) ⇒ void
This method returns an undefined value.
Replaces the existing list of plugins.
45 46 47 48 49 50 51 52 53 |
# File 'lib/seahorse/client/plugin_list.rb', line 45 def set(plugins) @mutex.synchronize do @plugins.clear plugins.each do |plugin| _add(plugin) end end nil end |