module Quovo::Scope

Public Instance Methods

current_scope(*args) click to toggle source
# File lib/quovo/scope.rb, line 11
def current_scope(*args)
  if args.any?
    Thread.current[:__quovo_scope__] = args.first
  else
    Thread.current[:__quovo_scope__] ||= {}
  end
end
scope(attributes) { || ... } click to toggle source
# File lib/quovo/scope.rb, line 3
def scope(attributes)
  parent = current_scope
  current_scope(current_scope.merge(attributes))
  result = yield if block_given?
  current_scope(parent)
  result
end