Class: Console::Output::Failure
- Defined in:
- lib/console/output/failure.rb
Overview
A wrapper for outputting failure messages, which can include exceptions.
Instance Attribute Summary
Attributes inherited from Wrapper
Instance Method Summary collapse
-
#call(subject = nil, *arguments, exception: nil, **options, &block) ⇒ Object
The exception must be either the last argument or passed as an option.
-
#initialize(output, **options) ⇒ Failure
constructor
A new instance of Failure.
Methods inherited from Wrapper
Constructor Details
#initialize(output, **options) ⇒ Failure
Returns a new instance of Failure.
13 14 15 |
# File 'lib/console/output/failure.rb', line 13 def initialize(output, **) super(output, **) end |
Instance Method Details
#call(subject = nil, *arguments, exception: nil, **options, &block) ⇒ Object
The exception must be either the last argument or passed as an option.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/console/output/failure.rb', line 18 def call(subject = nil, *arguments, exception: nil, **, &block) if exception.nil? last = arguments.last if last.is_a?(Exception) [:event] = Event::Failure.for(last) end elsif exception.is_a?(Exception) [:event] = Event::Failure.for(exception) else # We don't know what this is, so we just pass it through: [:exception] = exception end super(subject, *arguments, **) end |