Sha256: 510cc22c1b054cf2c2a0a4a9f6752731cb6b166aafde0773d7deb8417bfd9b79

Contents?: true

Size: 689 Bytes

Versions: 1

Compression:

Stored size: 689 Bytes

Contents

# frozen_string_literal: true

module CassandraObject
  module Scoping
    extend ActiveSupport::Concern

    included do
      singleton_class.class_eval do
        delegate :find, :find_by_id, :find_all_in_batches, :first, to: :scope
        delegate :select, :where, :where_ids, to: :scope
        delegate :cql_response, :columns, :limit, :per_page, 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

1 entries across 1 versions & 1 rubygems

Version Path
extendi-cassandra_object-1.1.1 lib/cassandra_object/scoping.rb