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.
14 15 16 17 18 19 20 21 22 |
# File 'lib/seahorse/client/plugin_list.rb', line 14 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`.
27 28 29 30 31 32 |
# File 'lib/seahorse/client/plugin_list.rb', line 27 def add(plugin) @mutex.synchronize do _add(plugin) end nil end |
#each(&block) ⇒ Enumerator
Enumerates the plugins.
59 60 61 62 63 |
# File 'lib/seahorse/client/plugin_list.rb', line 59 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`.
37 38 39 40 41 42 |
# File 'lib/seahorse/client/plugin_list.rb', line 37 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.
47 48 49 50 51 52 53 54 55 |
# File 'lib/seahorse/client/plugin_list.rb', line 47 def set(plugins) @mutex.synchronize do @plugins.clear plugins.each do |plugin| _add(plugin) end end nil end |