Class: Elevate::ElevateOperation
- Inherits:
-
NSOperation
- Object
- NSOperation
- Elevate::ElevateOperation
- Defined in:
- lib/elevate/operation.rb
Overview
Executes an Elevate task, firing callbacks along the way.
Instance Attribute Summary collapse
-
#exception ⇒ Exception?
readonly
Returns the exception that terminated this task, if any.
-
#result ⇒ Object?
readonly
Returns the result of the task block.
Instance Method Summary collapse
-
#cancel ⇒ void
Cancels the currently running task.
-
#initWithTarget(target, args: args, channel: channel) ⇒ ElevateOperation
private
Designated initializer.
-
#main ⇒ void
private
Runs the specified task.
-
#timeout ⇒ void
Cancels any waiting operation with a TimeoutError, interrupting execution.
Instance Attribute Details
#exception ⇒ Exception? (readonly)
Returns the exception that terminated this task, if any.
If the task has not finished, returns nil.
63 64 65 |
# File 'lib/elevate/operation.rb', line 63 def exception @exception end |
#result ⇒ Object? (readonly)
Returns the result of the task block.
If the task has not finished, returns nil.
73 74 75 |
# File 'lib/elevate/operation.rb', line 73 def result @result end |
Instance Method Details
#cancel ⇒ void
This method returns an undefined value.
Cancels the currently running task.
27 28 29 30 31 |
# File 'lib/elevate/operation.rb', line 27 def cancel @coordinator.cancel super end |
#initWithTarget(target, args: args, channel: channel) ⇒ ElevateOperation
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Designated initializer.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/elevate/operation.rb', line 11 def initWithTarget(target, args: args, channel: channel) if init @coordinator = IOCoordinator.new @context = TaskContext.new(target, channel, args) @exception = nil @result = nil end self end |
#main ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Runs the specified task.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/elevate/operation.rb', line 38 def main @coordinator.install begin unless @coordinator.cancelled? @result = @context.execute end rescue => e @exception = e end @coordinator.uninstall @context = nil end |
#timeout ⇒ void
This method returns an undefined value.
Cancels any waiting operation with a TimeoutError, interrupting execution. This is not the same as #cancel.
81 82 83 |
# File 'lib/elevate/operation.rb', line 81 def timeout @coordinator.cancel(TimeoutError) end |