Module: ThreadAncestors

Defined in:
lib/thread_ancestors.rb,
lib/thread_ancestors/version.rb

Constant Summary collapse

VERSION =
"0.1.1"

Instance Method Summary collapse

Instance Method Details

#ancestorsObject



7
8
9
10
11
12
13
14
# File 'lib/thread_ancestors.rb', line 7

def ancestors
  Enumerator.new do |enum|
    t = Thread.current
    while t = t.parent
      enum.yield t
    end
  end.lazy
end

#initializeObject



2
3
4
5
# File 'lib/thread_ancestors.rb', line 2

def initialize(*)
  @_parent = Thread.current
  super
end

#parentObject



16
17
18
# File 'lib/thread_ancestors.rb', line 16

def parent
  @_parent
end