thread-parent 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module ThreadParent
2
- VERSION = '1.0.2'
2
+ VERSION = '1.0.3'
3
3
  end
data/lib/thread_parent.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'thread_parent/version'
2
2
  require 'thread'
3
-
3
+ require 'pry'
4
4
  module ThreadParent
5
5
 
6
6
  class Parents
@@ -12,7 +12,7 @@ module ThreadParent
12
12
  def [](key)
13
13
  if @child.key?(key)
14
14
  @child[key]
15
- else
15
+ elsif @child.parent
16
16
  @child.parent.parents[key]
17
17
  end
18
18
  end
@@ -29,17 +29,13 @@ class Thread
29
29
  end
30
30
 
31
31
  def parent
32
- @_parent
32
+ @_parent #|| Thread.main
33
33
  end
34
34
 
35
35
  def parents
36
36
  ThreadParent::Parents.new(self)
37
37
  end
38
38
 
39
- def self.parent
40
- Thread.current.parent
41
- end
42
-
43
39
  def self.parents
44
40
  ThreadParent::Parents.new(Thread.current)
45
41
  end
@@ -42,4 +42,5 @@ class TestThreadParent < MiniTest::Unit::TestCase
42
42
  thread = Thread.new { 'work' }.join
43
43
  assert_equal('a', thread.parents[:a])
44
44
  end
45
+
45
46
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thread-parent
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2013-05-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70120867349120 !ruby/object:Gem::Requirement
16
+ requirement: &70233354825040 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70120867349120
24
+ version_requirements: *70233354825040
25
25
  description: ThreadParent facilitates spawning threads that maintain a reference to
26
26
  the thread that created them. The primary goal is to allow thread local variable
27
27
  lookup through the ancestor chain.