Class: ActiveShard::ScopeManager
- Inherits:
-
Object
- Object
- ActiveShard::ScopeManager
- Defined in:
- lib/active_shard/scope_manager.rb
Overview
ScopeManager handles the passing of messages to a Scope based on the current thread.
Allows consumers to operate on a Scope duck-typed object without handling the Thread local variable stuff.
Instance Method Summary collapse
- #active_shard_for_schema(*args) ⇒ Object
-
#initialize(options = {}) ⇒ ScopeManager
constructor
Initializes a scope manager.
- #pop(*args) ⇒ Object
- #push(*args) ⇒ Object
-
#scope_class ⇒ Object
Returns the current scope_class.
-
#scope_class=(klass) ⇒ Object
Sets the class to use for maintaining Thread-local scopes.
Constructor Details
#initialize(options = {}) ⇒ ScopeManager
Initializes a scope manager
19 20 21 |
# File 'lib/active_shard/scope_manager.rb', line 19 def initialize( ={} ) self.scope_class = [:scope_class] if [:scope_class] end |
Instance Method Details
#active_shard_for_schema(*args) ⇒ Object
37 38 39 |
# File 'lib/active_shard/scope_manager.rb', line 37 def active_shard_for_schema( *args ) scope.active_shard_for_schema( *args ) end |
#pop(*args) ⇒ Object
31 32 33 |
# File 'lib/active_shard/scope_manager.rb', line 31 def pop( *args ) scope.pop( *args ) end |
#push(*args) ⇒ Object
25 26 27 |
# File 'lib/active_shard/scope_manager.rb', line 25 def push( *args ) scope.push( *args ) end |
#scope_class ⇒ Object
Returns the current scope_class
56 57 58 |
# File 'lib/active_shard/scope_manager.rb', line 56 def scope_class @scope_class ||= Scope end |
#scope_class=(klass) ⇒ Object
Sets the class to use for maintaining Thread-local scopes
Instances of klass must respond to:
#push
#pop
#active_shard_for_schema
50 51 52 |
# File 'lib/active_shard/scope_manager.rb', line 50 def scope_class=( klass ) @scope_class = klass end |