Sha256: 233b68a932d08d09bcf199ddfb5bea7234fed215c2d7712eb1bea3c15639568e

Contents?: true

Size: 882 Bytes

Versions: 2

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_temp
          end
        else
          super
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
card-1.108.1 lib/card/query/card_class.rb
card-1.108.0 lib/card/query/card_class.rb