2011-12-15 15:07:41 -05:00
|
|
|
|
|
|
|
module ActiveRecord
|
|
|
|
module Scoping
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
2011-12-15 15:35:04 -05:00
|
|
|
included do
|
|
|
|
include Default
|
|
|
|
include Named
|
|
|
|
end
|
|
|
|
|
2011-12-15 15:07:41 -05:00
|
|
|
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
|