Class: Skywalker::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/skywalker/command.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(on_success: nil, on_failure: nil) ⇒ Command

Instantiates command, setting all arguments.



16
17
18
19
# File 'lib/skywalker/command.rb', line 16

def initialize(on_success: nil, on_failure: nil)
  self.on_success = on_success
  self.on_failure = on_failure
end

Instance Attribute Details

#errorObject

Returns the value of attribute error.



22
23
24
# File 'lib/skywalker/command.rb', line 22

def error
  @error
end

#on_failureObject

Returns the value of attribute on_failure.



22
23
24
# File 'lib/skywalker/command.rb', line 22

def on_failure
  @on_failure
end

#on_successObject

Returns the value of attribute on_success.



22
23
24
# File 'lib/skywalker/command.rb', line 22

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

#callObject

Call: runs the transaction and all operations.



30
31
32
33
34
35
36
37
38
39
# File 'lib/skywalker/command.rb', line 30

def call
  transaction do
    execute!

    confirm_success
  end

rescue Exception => error
  confirm_failure error
end