Module: Elastictastic::Scoped

Defined in:
lib/elastictastic/scoped.rb

Instance Method Summary collapse

Instance Method Details

#current_scopeObject



16
17
18
# File 'lib/elastictastic/scoped.rb', line 16

def current_scope
  scope_stack.last || default_scope
end

#scope_stackObject



12
13
14
# File 'lib/elastictastic/scoped.rb', line 12

def scope_stack
  Thread.current["#{name}::scope_stack"] ||= []
end

#with_scope(scope) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/elastictastic/scoped.rb', line 3

def with_scope(scope)
  scope_stack.push(scope)
  begin
    yield
  ensure
    scope_stack.pop
  end
end