Module: CurrentObject::ClassMethods
- Defined in:
- lib/current_object.rb
Instance Method Summary collapse
-
#clear_current! ⇒ Object
clear_current! - Have your class forget about the “current” instance.
-
#current ⇒ Object
current - Returns the instance of the class that is stored as the “current” instance.
Instance Method Details
#clear_current! ⇒ Object
clear_current! - Have your class forget about the “current” instance
@foo.current!
Foo.current # => @foo
Foo.clear_current! Foo.current # => nil
41 42 43 |
# File 'lib/current_object.rb', line 41 def clear_current! Thread.current[self.name] = nil end |
#current ⇒ Object
current - Returns the instance of the class that is stored as the “current” instance.
@foo.current!
Foo.current # => @foo
26 27 28 |
# File 'lib/current_object.rb', line 26 def current Thread.current[self.name] end |