Class: Charming::TaskEvent

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

Instance Method Summary collapse

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

#errorObject (readonly)

Returns the value of attribute error

Returns:

  • (Object)

    the current value of error



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

def error
  @error
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



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

def name
  @name
end

#valueObject (readonly)

Returns the value of attribute value

Returns:

  • (Object)

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

Returns:

  • (Boolean)


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

def error?
  !error.nil?
end