Class: Console::Event::Failure
- Defined in:
- lib/console/event/failure.rb
Overview
Represents a failure event.
“‘ruby Console::Event::Failure.for(exception).emit(self) “`
Instance Attribute Summary collapse
-
#exception ⇒ Object
readonly
Returns the value of attribute exception.
Class Method Summary collapse
Instance Method Summary collapse
- #emit(*arguments, **options) ⇒ Object
-
#initialize(exception, root = Dir.getwd) ⇒ Failure
constructor
A new instance of Failure.
- #to_hash ⇒ Object
Methods inherited from Generic
Constructor Details
Instance Attribute Details
#exception ⇒ Object (readonly)
Returns the value of attribute exception.
32 33 34 |
# File 'lib/console/event/failure.rb', line 32 def exception @exception end |
Class Method Details
.default_root ⇒ Object
18 19 20 21 22 |
# File 'lib/console/event/failure.rb', line 18 def self.default_root Dir.getwd rescue # e.g. Errno::EMFILE nil end |
.for(exception) ⇒ Object
24 25 26 |
# File 'lib/console/event/failure.rb', line 24 def self.for(exception) self.new(exception, self.default_root) end |
Instance Method Details
#emit(*arguments, **options) ⇒ Object
47 48 49 50 51 |
# File 'lib/console/event/failure.rb', line 47 def emit(*arguments, **) [:severity] ||= :error super end |
#to_hash ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/console/event/failure.rb', line 39 def to_hash Hash.new.tap do |hash| hash[:type] = :failure hash[:root] = @root if @root extract(@exception, hash) end end |