Module: RailsMultitenant::GlobalContextRegistry::CurrentInstance
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/rails_multitenant/global_context_registry/current_instance.rb
Overview
This module allows you to have a current, thread-local instance of a class. This module assumes that you are mixing into a Rails model, and separately stores and id in thread local storage for lazy loading.
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
Instance Method Details
#as_current ⇒ Object
90 91 92 93 94 95 96 |
# File 'lib/rails_multitenant/global_context_registry/current_instance.rb', line 90 def as_current old_id = self.class.current_id self.class.current = self yield ensure self.class.current_id = old_id end |
#current? ⇒ Boolean
98 99 100 |
# File 'lib/rails_multitenant/global_context_registry/current_instance.rb', line 98 def current? id == self.class.current_id end |