Sha256: 1d8fbc441ec787bacbdbcbb48b43b939ca705fc537b07242c9fe9da4bf40c7c8

Contents?: true

Size: 623 Bytes

Versions: 20

Compression:

Stored size: 623 Bytes

Contents

module Superstore
  module Scoping
    extend ActiveSupport::Concern

    included do
      singleton_class.class_eval do
        delegate :find, :find_by_id, :first, :all, to: :scope
        delegate :find_each, :find_in_batches, to: :scope
        delegate :select, :where, :where_ids, to: :scope
      end
    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

20 entries across 20 versions & 1 rubygems

Version Path
superstore-2.0.1 lib/superstore/scoping.rb
superstore-2.0.0 lib/superstore/scoping.rb
superstore-1.2.0 lib/superstore/scoping.rb
superstore-1.1.4 lib/superstore/scoping.rb
superstore-1.1.3 lib/superstore/scoping.rb
superstore-1.1.2 lib/superstore/scoping.rb
superstore-1.1.1 lib/superstore/scoping.rb
superstore-1.1.0 lib/superstore/scoping.rb
superstore-1.0.12 lib/superstore/scoping.rb
superstore-1.0.11 lib/superstore/scoping.rb
superstore-1.0.10 lib/superstore/scoping.rb
superstore-1.0.9 lib/superstore/scoping.rb
superstore-1.0.8 lib/superstore/scoping.rb
superstore-1.0.7 lib/superstore/scoping.rb
superstore-1.0.6 lib/superstore/scoping.rb
superstore-1.0.5 lib/superstore/scoping.rb
superstore-1.0.4 lib/superstore/scoping.rb
superstore-1.0.3 lib/superstore/scoping.rb
superstore-1.0.2 lib/superstore/scoping.rb
superstore-1.0.0 lib/superstore/scoping.rb