class Qonfig::CommandSet
@api private @since 0.1.0
Attributes
commands[R]
@return [Array<Qonfig::Commands::Base>]
@api private @since 0.1.0
Public Class Methods
new()
click to toggle source
@return [void]
@api private @since 0.1.0
# File lib/qonfig/command_set.rb, line 20 def initialize @commands = [] @access_lock = Mutex.new end
Public Instance Methods
add_command(command)
click to toggle source
@param command [Qonfig::Commands::Base] @return [void]
@api private @since 0.1.0
# File lib/qonfig/command_set.rb, line 30 def add_command(command) thread_safe { commands << command } end
Also aliased as: <<
concat(command_set) { |command| ... }
click to toggle source
@param command_set [Qonfig::CommandSet] @param concat_condition [Block] @yield [command] @yieldparam command [Qonfig::Commands::Base] @return [void]
@api private @since 0.1.0 @version 0.19.0
# File lib/qonfig/command_set.rb, line 53 def concat(command_set, &concant_condition) thread_safe do if block_given? command_set.each { |command| (commands << command) if yield(command) } else command_set.each { |command| commands << command } end end end
dup()
click to toggle source
@return [Qonfig::CommandSet]
@api private @since 0.2.0
# File lib/qonfig/command_set.rb, line 67 def dup thread_safe do self.class.new.tap { |duplicate| duplicate.concat(self) } end end
each(&block)
click to toggle source
@param block [Proc] @return [Enumerable]
@api private @since 0.1.0
# File lib/qonfig/command_set.rb, line 40 def each(&block) thread_safe { block_given? ? commands.each(&block) : commands.each } end
Private Instance Methods
thread_safe() { |: synchronize(&block)| ... }
click to toggle source
@param block [Proc] @return [Any]
@api private @since 0.2.0 @version 0.19.0
# File lib/qonfig/command_set.rb, line 81 def thread_safe(&block) @access_lock.owned? ? yield : @access_lock.synchronize(&block) end