<commit_before># ThreadVariable

[![Build Status](https://secure.travis-ci.org/amarshall/thread_variable.png)](http://travis-ci.org/amarshall/thread_variable)
[![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/amarshall/thread_variable)

Makes it easy to create and use thread-local variables. This encapsulates two patterns:

- The `Thread.current` hash is not namespaced, which can make name collision between different libraries or parts of an app very possible. ThreadVariable gets around this by namespacing variables under the current class/module name.
- Accessing and setting `Thread.current` is not so pretty to look at, so ThreadVariable creates a getter and setter for each thread variable.

## Installation

Install as your normally would, nothing special here. Only compatible with Ruby 1.9+.

## Usage

Simply `extend ThreadVariable` and call `thread_variable` in classes you want thread variables in:

    class C
      extend ThreadVariable
      thread_variable :foo
    end

    C.foo = 'bar'

    Thread.new do
      C.foo = 'baz'
      C.foo  #=> "baz"
    end.join

    C.foo  #=> "bar"

If you don’t want to `extend ThreadVariable` everywhere you can instead do

    require 'thread_variable/core_ext'

which will `include ThreadVariable` in both `Class` & `Module`.

For more, just read the source. Seriously, go read it—it’s less than 20 lines and will only take a minute.

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

## Credits & License

Copyright © 2012 <NAME>. All rights reserved.
License is available in the LICENSE file.<commit_msg>Syntax highlighting in readme<commit_after># ThreadVariable

[![Build Status](https://secure.travis-ci.org/amarshall/thread_variable.png)](http://travis-ci.org/amarshall/thread_variable)
[![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/amarshall/thread_variable)

Makes it easy to create and use thread-local variables. This encapsulates two patterns:

- The `Thread.current` hash is not namespaced, which can make name collision between different libraries or parts of an app very possible. ThreadVariable gets around this by namespacing variables under the current class/module name.
- Accessing and setting `Thread.current` is not so pretty to look at, so ThreadVariable creates a getter and setter for each thread variable.

## Installation

Install as your normally would, nothing special here. Only compatible with Ruby 1.9+.

## Usage

Simply `extend ThreadVariable` and call `thread_variable` in classes you want thread variables in:

```ruby
class C
  extend ThreadVariable
  thread_variable :foo
end

C.foo = 'bar'

Thread.new do
  C.foo = 'baz'
  C.foo  #=> "baz"
end.join

C.foo  #=> "bar"
```

If you don’t want to `extend ThreadVariable` everywhere you can instead do

```ruby
require 'thread_variable/core_ext'
```

which will `include ThreadVariable` in both `Class` & `Module`.

For more, just read the source. Seriously, go read it—it’s less than 20 lines and will only take a minute.

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

## Credits & License

Copyright © 2012 <NAME>. All rights reserved.
License is available in the LICENSE file.
{'fraction_non_alphanumeric': 0.09334823923979876, 'fraction_numerical': 0.0072666294019005035, 'mean_word_length': 4.217201166180758, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '584847', 'n_tokens_mistral': 1060, 'n_tokens_neox': 1005, 'n_words': 434}