Class: SmartCore::Container::DefinitionDSL::CommandSet Private

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/smart_core/container/definition_dsl/command_set.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.

Since:

  • 0.1.0

Version:

  • 0.11.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializevoid

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.

Since:

  • 0.1.0

Version:

  • 0.11.0



21
22
23
24
# File 'lib/smart_core/container/definition_dsl/command_set.rb', line 21

def initialize
  @commands = []
  @lock = SmartCore::Engine::ReadWriteLock.new
end

Instance Attribute Details

#commandsArray<SmartCore::Container::DefinitionDSL::Commands::Base> (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.



14
15
16
# File 'lib/smart_core/container/definition_dsl/command_set.rb', line 14

def commands
  @commands
end

Instance Method Details

#add_command(command) ⇒ void Also known as: <<

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.

This method returns an undefined value.

Parameters:

Since:

  • 0.1.0

Version:

  • 0.11.0



32
33
34
# File 'lib/smart_core/container/definition_dsl/command_set.rb', line 32

def add_command(command)
  @lock.write_sync { commands << command }
end

#concat(command_set, &concat_condition) {|command| ... } ⇒ void

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.

This method returns an undefined value.

Parameters:

Yields:

  • (command)

Yield Parameters:

Since:

  • 0.1.0

Version:

  • 0.11.0



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/smart_core/container/definition_dsl/command_set.rb', line 56

def concat(command_set, &concat_condition)
  @lock.read_sync do
    if block_given?
      command_set.dup.each { |command| (commands << command) if yield(command) }
    else
      # :nocov:
      commands.concat(command_set.dup.commands) # NOTE: unreachable code at this moment
      # :nocov:
    end
  end
end

#dupSmartCore::Container::DefinitionDSL::CommandSet

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:

Since:

  • 0.1.0

Version:

  • 0.11.0



73
74
75
76
77
78
79
80
81
# File 'lib/smart_core/container/definition_dsl/command_set.rb', line 73

def dup
  @lock.read_sync do
    self.class.new.tap do |duplicate|
      commands.each do |command|
        duplicate.add_command(command.dup)
      end
    end
  end
end

#each(&block) ⇒ Enumerable

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.

Parameters:

  • block (Block)

Returns:

  • (Enumerable)

Since:

  • 0.1.0

Version:

  • 0.11.0



43
44
45
# File 'lib/smart_core/container/definition_dsl/command_set.rb', line 43

def each(&block)
  @lock.read_sync { block_given? ? commands.each(&block) : commands.each }
end