Module: Smooth::Command::Instrumented
- Included in:
- Smooth::Command
- Defined in:
- lib/smooth/command/instrumented.rb
Defined Under Namespace
Modules: ClassMethods, Overrides, Restored
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.included(base) ⇒ Object
4
5
6
7
|
# File 'lib/smooth/command/instrumented.rb', line 4
def self.included(base)
base.extend(ClassMethods)
base.enable_event_tracking! end
|
Instance Method Details
#run_with_instrumentation(event_prefix = nil) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/smooth/command/instrumented.rb', line 32
def run_with_instrumentation(event_prefix = nil)
outcome = run_with_outcome
event_prefix = "#{ event_prefix }." if event_prefix
if outcome.success?
result = outcome.result
track_event("#{ event_prefix }#{ event_namespace }", result: result, inputs: inputs, current_user: current_user)
outcome
else
track_event("errors/#{ event_prefix }#{ event_namespace }", errors: outcome.errors, inputs: inputs, current_user: current_user)
outcome
end
end
|
#run_with_outcome ⇒ Object
47
48
49
50
|
# File 'lib/smooth/command/instrumented.rb', line 47
def run_with_outcome
return validation_outcome if has_errors?
validation_outcome(execute)
end
|