Class: ComposedCommands::Command
- Inherits:
-
Object
- Object
- ComposedCommands::Command
- Extended by:
- ActiveSupport::Autoload
- Defined in:
- lib/composed_commands/command.rb,
lib/composed_commands/command/state.rb,
lib/composed_commands/command/execution.rb
Direct Known Subclasses
Defined Under Namespace
Instance Attribute Summary collapse
-
#execution ⇒ Object
Returns the value of attribute execution.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#state ⇒ Object
Returns the value of attribute state.
Class Method Summary collapse
Instance Method Summary collapse
- #halted? ⇒ Boolean
-
#initialize(options = {}) ⇒ Command
constructor
A new instance of Command.
- #perform(*args) ⇒ Object
Constructor Details
Instance Attribute Details
#execution ⇒ Object
Returns the value of attribute execution.
15 16 17 |
# File 'lib/composed_commands/command.rb', line 15 def execution @execution end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
14 15 16 |
# File 'lib/composed_commands/command.rb', line 14 def @message end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
13 14 15 |
# File 'lib/composed_commands/command.rb', line 13 def result @result end |
#state ⇒ Object
Returns the value of attribute state.
16 17 18 |
# File 'lib/composed_commands/command.rb', line 16 def state @state end |
Class Method Details
.perform(*args) ⇒ Object
26 27 28 29 |
# File 'lib/composed_commands/command.rb', line 26 def self.perform(*args) = args. new().perform(*args) end |
Instance Method Details
#halted? ⇒ Boolean
42 43 44 |
# File 'lib/composed_commands/command.rb', line 42 def halted? execution.interrupted? end |
#perform(*args) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/composed_commands/command.rb', line 31 def perform(*args) @result = catch(:halt) do execution.perform! result = execute(*args) state.success! execution.done! result end self end |