Sha256: 346872c78765cff73bd8f4bef96ebd1c69bf353adb5702b499b06693ab5c7d17
Contents?: true
Size: 753 Bytes
Versions: 10
Compression:
Stored size: 753 Bytes
Contents
module Superstore module Scoping extend ActiveSupport::Concern included do singleton_class.class_eval do delegate :find, :find_by_id, :first, :all, :to_ids, to: :scope delegate :find_each, :find_in_batches, to: :scope delegate :select, :where, :where_ids, to: :scope end class_attribute :default_scopes, instance_writer: false, instance_predicate: false self.default_scopes = [] end module ClassMethods def scope self.current_scope ||= Scope.new(self) end def current_scope Thread.current["#{self}_current_scope"] end def current_scope=(new_scope) Thread.current["#{self}_current_scope"] = new_scope end end end end
Version data entries
10 entries across 10 versions & 1 rubygems