Sha256: dd62af8721a296587b50a9926e24d249ff44cf174d4cdda3c891b4e46bfbf3f6

Contents?: true

Size: 583 Bytes

Versions: 75

Compression:

Stored size: 583 Bytes

Contents

require 'thread'

module ThreadParent
  class Parents

    def initialize(child)
      @child = child
    end

    def [](key)
      if @child.key?(key)
        @child[key]
      elsif @child.parent
        @child.parent.parents[key]
      end
    end
  end
end

class Thread

  alias_method :_initialize, :initialize

  def initialize(*args, &block)
    @_parent = Thread.current
    _initialize(*args, &block)
  end

  def parent
    @_parent
  end

  def parents
    ThreadParent::Parents.new(self)
  end

  def self.parents
    ThreadParent::Parents.new(Thread.current)
  end
end

Version data entries

75 entries across 75 versions & 1 rubygems

Version Path
ree_lib-1.0.84 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.83 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.82 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.81 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.80 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.79 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.78 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.77 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.76 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.75 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.74 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.73 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.72 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.71 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.70 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.69 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.68 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.67 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.66 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.65 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb