Class: Charming::TaskEvent
- Inherits:
-
Data
- Object
- Data
- Charming::TaskEvent
- Defined in:
- lib/charming/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.
8 9 10 |
# File 'lib/charming/task_event.rb', line 8 def initialize(name:, value: nil, error: nil) super end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error
7 8 9 |
# File 'lib/charming/task_event.rb', line 7 def error @error end |
#name ⇒ Object (readonly)
Returns the value of attribute name
7 8 9 |
# File 'lib/charming/task_event.rb', line 7 def name @name end |
#value ⇒ Object (readonly)
Returns the value of attribute value
7 8 9 |
# File 'lib/charming/task_event.rb', line 7 def value @value end |
Instance Method Details
#error? ⇒ Boolean
Returns ‘true` when the task finished with a non-nil exception.
13 14 15 |
# File 'lib/charming/task_event.rb', line 13 def error? !error.nil? end |