Module: RailsMultitenant::GlobalContextRegistry::Current
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/rails_multitenant/global_context_registry/current.rb
Overview
This module allows your to have a current, thread-local instance of this class. It currently assumes your class has a zero-arg constructor.
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
Instance Method Details
#as_current ⇒ Object
91 92 93 94 95 96 97 |
# File 'lib/rails_multitenant/global_context_registry/current.rb', line 91 def as_current old_object = self.class.current if self.class.current? self.class.current = self yield ensure self.class.current = old_object end |
#current? ⇒ Boolean
99 100 101 |
# File 'lib/rails_multitenant/global_context_registry/current.rb', line 99 def current? self.class.current? && equal?(self.class.current) end |