Class: Elevate::TaskContext Private

Inherits:
Object
  • Object
show all
Defined in:
lib/elevate/task_context.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A blank slate for hosting task blocks.

Because task blocks run in another thread, it is dangerous to expose them to the calling context. This class acts as a sandbox for task blocks.

Instance Method Summary collapse

Constructor Details

#initialize(block, channel, args) ⇒ TaskContext

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.

Returns a new instance of TaskContext.



9
10
11
12
13
# File 'lib/elevate/task_context.rb', line 9

def initialize(block, channel, args)
  @__block = block
  @__channel = channel
  @__args = args
end

Instance Method Details

#executeObject

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.



15
16
17
# File 'lib/elevate/task_context.rb', line 15

def execute
  instance_exec(&@__block)
end

#task_argsObject

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.



19
20
21
# File 'lib/elevate/task_context.rb', line 19

def task_args
  @__args
end

#update(*args) ⇒ Object

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.



23
24
25
# File 'lib/elevate/task_context.rb', line 23

def update(*args)
  @__channel << args if @__channel
end