Class: Charming::Events::TaskEvent
- Inherits:
-
Data
- Object
- Data
- Charming::Events::TaskEvent
- Defined in:
- lib/charming/events/task_event.rb
Overview
TaskEvent represents background task completion. name is the declared task identifier, value carries the return result and error captures any exception raised during execution. The ‘error?` predicate simplifies error handling in controller handlers.
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#error? ⇒ Boolean
Returns ‘true` when the task finished with a non-nil exception.
-
#initialize(name:, value: nil, error: nil) ⇒ TaskEvent
constructor
A new instance of TaskEvent.
Constructor Details
#initialize(name:, value: nil, error: nil) ⇒ TaskEvent
Returns a new instance of TaskEvent.
9 10 11 |
# File 'lib/charming/events/task_event.rb', line 9 def initialize(name:, value: nil, error: nil) super end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error
8 9 10 |
# File 'lib/charming/events/task_event.rb', line 8 def error @error end |
#name ⇒ Object (readonly)
Returns the value of attribute name
8 9 10 |
# File 'lib/charming/events/task_event.rb', line 8 def name @name end |
#value ⇒ Object (readonly)
Returns the value of attribute value
8 9 10 |
# File 'lib/charming/events/task_event.rb', line 8 def value @value end |
Instance Method Details
#error? ⇒ Boolean
Returns ‘true` when the task finished with a non-nil exception.
14 15 16 |
# File 'lib/charming/events/task_event.rb', line 14 def error? !error.nil? end |