Class: Charming::Events::TaskEvent

Inherits:
Data
  • Object
show all
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

Instance Method Summary collapse

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

#errorObject (readonly)

Returns the value of attribute error

Returns:

  • (Object)

    the current value of error



8
9
10
# File 'lib/charming/events/task_event.rb', line 8

def error
  @error
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



8
9
10
# File 'lib/charming/events/task_event.rb', line 8

def name
  @name
end

#valueObject (readonly)

Returns the value of attribute value

Returns:

  • (Object)

    the current value of 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.

Returns:

  • (Boolean)


14
15
16
# File 'lib/charming/events/task_event.rb', line 14

def error?
  !error.nil?
end