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
43 44 45 |
# File 'lib/current_object.rb', line 43 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
28 29 30 |
# File 'lib/current_object.rb', line 28 def current Thread.current[self.name] end |