Module: TurboBoost::Commands::CommandCallbacks

Extended by:
ActiveSupport::Concern
Includes:
ActiveSupport::Callbacks, 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

#aborted?Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/turbo_boost/commands/command_callbacks.rb', line 87

def aborted?
  !!@aborted
end

#errored?Boolean

Returns:

  • (Boolean)


91
92
93
# File 'lib/turbo_boost/commands/command_callbacks.rb', line 91

def errored?
  !!@errored
end

#perform_with_callbacks(method_name) ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
# File 'lib/turbo_boost/commands/command_callbacks.rb', line 75

def perform_with_callbacks(method_name)
  @performing_method_name = method_name
  run_callbacks NAME do
    public_send method_name
    performed!
  end
rescue => error
  errored! error
ensure
  @performing_method_name = nil
end

#performed?Boolean

Returns:

  • (Boolean)


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

def performed?
  !!@performed
end

#performing?Boolean

Returns:

  • (Boolean)


95
96
97
# File 'lib/turbo_boost/commands/command_callbacks.rb', line 95

def performing?
  !!@performing_method_name
end

#succeeded?Boolean

Returns:

  • (Boolean)


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

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