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.104 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.103 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.102 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.101 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.100 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.99 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.98 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.97 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.96 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.95 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.94 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.93 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.92 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.91 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.90 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.89 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.88 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.87 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.86 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb
ree_lib-1.0.85 lib/ree_lib/packages/ree_dao/package/ree_dao/thread_parents.rb