Module: TurboBoost::Commands::CommandCallbacks

Extended by:
ActiveSupport::Concern
Includes:
ActiveSupport::Callbacks, ActiveSupport::Rescuable, Observable
Included in:
Command
Defined in:
lib/turbo_boost/commands/command_callbacks.rb

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

NAME =
:perform_command

Instance Method Summary collapse

Instance Method Details

#abort_handler(error = nil) ⇒ Object



120
121
122
# File 'lib/turbo_boost/commands/command_callbacks.rb', line 120

def abort_handler(error = nil)
  # noop, override in subclasses via `on_abort`
end

#aborted?Boolean

Returns:

  • (Boolean)


100
101
102
# File 'lib/turbo_boost/commands/command_callbacks.rb', line 100

def aborted?
  !!@aborted
end

#error_handler(error) ⇒ Object



124
125
126
# File 'lib/turbo_boost/commands/command_callbacks.rb', line 124

def error_handler(error)
  # noop, override in subclasses via `on_error`
end

#errored?Boolean

Returns:

  • (Boolean)


104
105
106
# File 'lib/turbo_boost/commands/command_callbacks.rb', line 104

def errored?
  !!@errored
end

#perform_with_callbacks(method_name) ⇒ Object



88
89
90
91
92
93
94
95
96
97
98
# File 'lib/turbo_boost/commands/command_callbacks.rb', line 88

def perform_with_callbacks(method_name)
  @performing_method_name = method_name
  run_callbacks NAME do
    public_send method_name
    performed!
  end
rescue => error
  errored! TurboBoost::Commands::PerformError.new(command: self, cause: error)
ensure
  @performing_method_name = nil
end

#performed?Boolean

Returns:

  • (Boolean)


112
113
114
# File 'lib/turbo_boost/commands/command_callbacks.rb', line 112

def performed?
  !!@performed
end

#performing?Boolean

Returns:

  • (Boolean)


108
109
110
# File 'lib/turbo_boost/commands/command_callbacks.rb', line 108

def performing?
  !!@performing_method_name
end

#succeeded?Boolean

Returns:

  • (Boolean)


116
117
118
# File 'lib/turbo_boost/commands/command_callbacks.rb', line 116

def succeeded?
  performed? && !aborted? && !errored?
end