Module: Quovo::Scope
- Included in:
- Quovo
- Defined in:
- lib/quovo/scope.rb
Instance Method Summary collapse
Instance Method Details
#current_scope(*args) ⇒ Object
11 12 13 14 15 16 17 |
# 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) ⇒ Object
3 4 5 6 7 8 9 |
# 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 |