current_object 0.1 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module CurrentObject
2
- VERSION = '0.1'
2
+ VERSION = '0.2'
3
3
  end
@@ -26,5 +26,20 @@ module CurrentObject
26
26
  def current
27
27
  Thread.current[self.name]
28
28
  end
29
+
30
+ # clear_current! - Have your class forget about the "current" instance
31
+ #
32
+ # @foo = Foo.new
33
+ # @foo.current!
34
+ #
35
+ # Foo.current
36
+ # # => @foo
37
+ #
38
+ # Foo.clear_current!
39
+ # Foo.current
40
+ # # => nil
41
+ def clear_current!
42
+ Thread.current[self.name] = nil
43
+ end
29
44
  end
30
45
  end
@@ -24,4 +24,13 @@ describe Foo do
24
24
  Foo.current.should == @foo
25
25
  end
26
26
  end
27
+
28
+ describe '.clear_current!' do
29
+ it 'forgets about the instance you made current' do
30
+ @foo.current!
31
+ Foo.clear_current!
32
+
33
+ Foo.current.should be_nil
34
+ end
35
+ end
27
36
  end
metadata CHANGED
@@ -4,8 +4,8 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
8
- version: "0.1"
7
+ - 2
8
+ version: "0.2"
9
9
  platform: ruby
10
10
  authors:
11
11
  - Dane Harrigan
@@ -13,7 +13,7 @@ autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
15
 
16
- date: 2010-12-08 00:00:00 -05:00
16
+ date: 2010-12-09 00:00:00 -05:00
17
17
  default_executable:
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency