Class: Lite::Command::FaultStreamer
- Inherits:
-
Object
- Object
- Lite::Command::FaultStreamer
- Defined in:
- lib/lite/command/fault_streamer.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Instance Method Summary collapse
- #caused_by ⇒ Object
- #command_exception ⇒ Object
-
#initialize(command, object) ⇒ FaultStreamer
constructor
A new instance of FaultStreamer.
- #metadata ⇒ Object
- #reason ⇒ Object
- #thrown_by ⇒ Object
Constructor Details
#initialize(command, object) ⇒ FaultStreamer
Returns a new instance of FaultStreamer.
9 10 11 12 |
# File 'lib/lite/command/fault_streamer.rb', line 9 def initialize(command, object) @command = command @object = object end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
7 8 9 |
# File 'lib/lite/command/fault_streamer.rb', line 7 def command @command end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
7 8 9 |
# File 'lib/lite/command/fault_streamer.rb', line 7 def object @object end |
Instance Method Details
#caused_by ⇒ Object
28 29 30 |
# File 'lib/lite/command/fault_streamer.rb', line 28 def caused_by Utils.try(object, :caused_by) || command end |
#command_exception ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/lite/command/fault_streamer.rb', line 38 def command_exception return if command.success? Fault.build( command.status.capitalize, command, object, dynamic: command.send(:raise_dynamic_faults?) ) end |
#metadata ⇒ Object
24 25 26 |
# File 'lib/lite/command/fault_streamer.rb', line 24 def Utils.try(object, :metadata) || command. end |
#reason ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/lite/command/fault_streamer.rb', line 14 def reason if object.respond_to?(:reason) object.reason elsif object.is_a?(StandardError) Utils.pretty_exception(object) else object end end |