README.md in thread-parent-1.0.1 vs README.md in thread-parent-1.0.2
- old
+ new
@@ -17,49 +17,49 @@
$ gem install thread-parent
## Usage
-You can either create ThreadParent::Thread directly:
+Thread is extended to provide direct access to its 'parent', or the thread where the current
+thread was created. It also provides a way to lookup through its ancestor chain for Thread-local variables.
```ruby
-require 'thread-parent'
+require 'thread_parent'
Thread.current[:abc] = 'abc'
-ThreadParent::Thread.new do |thread|
+Thread.new do |thread|
- thread.parent == Thread.main #= true
+ thread.parent == Thread.main #=> true
- # Since the thread variable isn't set locally it will be found in its parent.
- Thread.current[:abc] #= 'abc'
+ # Standard local variable lookup behaves as expected.
+ thread[:abc] #=> nil
- # Local thread variable assignments work as expected.
- Thread.current[:def] = 'def'
+ # Lookup through the ancestor chain is now supported.
+ thread.parents[:abc] #=> 'abc'
- ThreadParent::Thread.new do
- Thread.current[:def] #= 'def'
+ # Local thread variable assignments works as expected.
+ thread[:def] = 'def'
+ thread[:def] #=> 'def'
+ thread.parents[:def] #=> 'def' <- The calling thread is always checked first.
+ # Short-hand references to the current thread's parents is also provided.
+ Thread.parents[:abc] #=> 'abc'
+ Thread.parent == Thread.main #=> true
+
+ Thread.new do
+ Thread.parents[:def] #= 'def'
+
# The parent lookup will continue to the parent's parent until a variable is found.
- Thread.current[:abc] #= 'abc'
+ Thread.parents[:abc] #= 'abc'
end
end
```
-Or include the module to hijack references to Thread:
-
-```ruby
-require 'thread-parent'
-include ThreadParent
-
-Thread.new do
- # This is really a ThreadParent::Thread
-end
-```
-
## Code Status
[![Build Status](https://api.travis-ci.org/mje113/thread-parent.png)](http://travis-ci.org/mje113/thread-parent)
+[![Code Climate](https://codeclimate.com/github/mje113/thread-parent.png)](https://codeclimate.com/github/mje113/thread-parent)
## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)