mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
31 lines
642 B
Ruby
31 lines
642 B
Ruby
require 'active_support/concern'
|
|
|
|
module ActiveRecord
|
|
module Scoping
|
|
extend ActiveSupport::Concern
|
|
|
|
included do
|
|
include Default
|
|
include Named
|
|
end
|
|
|
|
module ClassMethods
|
|
def current_scope #:nodoc:
|
|
Thread.current["#{self}_current_scope"]
|
|
end
|
|
|
|
def current_scope=(scope) #:nodoc:
|
|
Thread.current["#{self}_current_scope"] = scope
|
|
end
|
|
end
|
|
|
|
def populate_with_current_scope_attributes
|
|
return unless self.class.scope_attributes?
|
|
|
|
self.class.scope_attributes.each do |att,value|
|
|
send("#{att}=", value) if respond_to?("#{att}=")
|
|
end
|
|
end
|
|
|
|
end
|
|
end
|