Class: Skywalker::Command
- Inherits:
-
Object
- Object
- Skywalker::Command
- Defined in:
- lib/skywalker/command.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
Returns the value of attribute error.
-
#on_failure ⇒ Object
Returns the value of attribute on_failure.
-
#on_success ⇒ Object
Returns the value of attribute on_success.
Class Method Summary collapse
-
.call(*args) ⇒ Object
Class interface.
Instance Method Summary collapse
-
#call ⇒ Object
Call: runs the transaction and all operations.
-
#initialize(**args) ⇒ Command
constructor
Instantiates command, setting all arguments.
Constructor Details
#initialize(**args) ⇒ Command
Instantiates command, setting all arguments.
16 17 18 19 20 21 22 23 24 |
# File 'lib/skywalker/command.rb', line 16 def initialize(**args) args.each_pair do |k, v| singleton_class.class_eval do send(:attr_accessor, k) unless self.respond_to? k end self.send("#{k}=", v) end end |
Instance Attribute Details
#error ⇒ Object
Returns the value of attribute error.
27 28 29 |
# File 'lib/skywalker/command.rb', line 27 def error @error end |
#on_failure ⇒ Object
Returns the value of attribute on_failure.
27 28 29 |
# File 'lib/skywalker/command.rb', line 27 def on_failure @on_failure end |
#on_success ⇒ Object
Returns the value of attribute on_success.
27 28 29 |
# File 'lib/skywalker/command.rb', line 27 def on_success @on_success end |
Class Method Details
.call(*args) ⇒ Object
Class interface
8 9 10 |
# File 'lib/skywalker/command.rb', line 8 def self.call(*args) new(*args).call end |
Instance Method Details
#call ⇒ Object
Call: runs the transaction and all operations.
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/skywalker/command.rb', line 35 def call transaction do execute! confirm_success end rescue Exception => error confirm_failure error end |