current_object 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/current_object/version.rb +1 -1
- data/lib/current_object.rb +15 -0
- data/spec/current_object_spec.rb +9 -0
- metadata +3 -3
data/lib/current_object.rb
CHANGED
@@ -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
|
data/spec/current_object_spec.rb
CHANGED
metadata
CHANGED
@@ -4,8 +4,8 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
version: "0.
|
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-
|
16
|
+
date: 2010-12-09 00:00:00 -05:00
|
17
17
|
default_executable:
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|