class Seahorse::Client::PluginList
Public Class Methods
new(plugins = [], options = {})
click to toggle source
@param [Array, Set] plugins @option options [Mutex] :mutex
# File lib/seahorse/client/plugin_list.rb, line 12 def initialize(plugins = [], options = {}) @mutex = options[: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
Public Instance Methods
add(plugin)
click to toggle source
Adds and returns the `plugin`. @param [Plugin] plugin @return [void]
# File lib/seahorse/client/plugin_list.rb, line 25 def add(plugin) @mutex.synchronize do _add(plugin) end nil end
each() { |plugin| ... }
click to toggle source
Enumerates the plugins. @return [Enumerator]
# 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)
click to toggle source
Removes and returns the `plugin`. @param [Plugin] plugin @return [void]
# 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)
click to toggle source
Replaces the existing list of plugins. @param [Array<Plugin>] plugins @return [void]
# 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
Private Instance Methods
_add(plugin)
click to toggle source
Not safe to call outside the mutex.
# File lib/seahorse/client/plugin_list.rb, line 66 def _add(plugin) @plugins << PluginWrapper.new(plugin) end
each_plugin(&block)
click to toggle source
Yield each PluginDetail behind the mutex
# File lib/seahorse/client/plugin_list.rb, line 71 def each_plugin(&block) @mutex.synchronize do @plugins.each(&block) end end