Sha256: 13262fd63718c7273903f69cefd7505c43224260225b5cd0e56ea3d49873a9da

Contents?: true

Size: 882 Bytes

Versions: 10

Compression:

Stored size: 882 Bytes

Contents

class Card
  module Query
    module CardClass
      def search spec, comment=nil, &block
        results = ::Card::Query.run(spec, comment)
        results.each(&block) if block_given? && results.is_a?(Array)
        results
      end

      def count_by_cql spec
        spec = spec.clone
        spec.delete(:offset)
        search spec.merge(return: "count")
      end

      def find_each **options, &block
        # this is a copy from rails (3.2.16) and is needed because this
        # is performed by a relation (ActiveRecord::Relation)
        find_in_batches(**options) do |records|
          records.each(&block)
        end
      end

      def find_in_batches **options
        if block_given?
          super do |records|
            yield(records)
            Card::Cache.reset_soft
          end
        else
          super
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
card-1.107.0 lib/card/query/card_class.rb
card-1.106.0 lib/card/query/card_class.rb
card-1.105.6 lib/card/query/card_class.rb
card-1.105.5 lib/card/query/card_class.rb
card-1.105.4 lib/card/query/card_class.rb
card-1.105.3 lib/card/query/card_class.rb
card-1.105.2.pre1 lib/card/query/card_class.rb
card-1.105.2 lib/card/query/card_class.rb
card-1.105.1 lib/card/query/card_class.rb
card-1.105.0 lib/card/query/card_class.rb