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(args, &block) ⇒ 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
14
15
16
# File 'lib/elevate/task_context.rb', line 9

def initialize(args, &block)
  metaclass = class << self; self; end
  metaclass.send(:define_method, :execute, &block)

  args.each do |key, value|
    instance_variable_set("@#{key}", value)
  end
end