Sha256: 7c684f3a707002d165453c5df76d54ef93d984e5a2ed50c14d015ce34b3949a5

Contents?: true

Size: 552 Bytes

Versions: 1

Compression:

Stored size: 552 Bytes

Contents

module Elevate
  # 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.
  #
  # @api private
  class TaskContext
    def initialize(block, channel, args)
      @__block = block
      @__channel = channel
      @__args = args
    end

    def execute
      instance_exec(&@__block)
    end

    def task_args
      @__args
    end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
elevate-0.7.0 lib/elevate/task_context.rb