Sha256: 1bac192ff67c2558d8e046f4b8cfc7b0bdf51cab5a53b7d1780be3023644f9b4

Contents?: true

Size: 534 Bytes

Versions: 5

Compression:

Stored size: 534 Bytes

Contents

module ActiveRecord
  class Relation

    def qry_options(*args)
      DirectiveRecord::Relation.new(self).qry_options(*args)
    end

    def to_qry(*args)
      klass.to_qry qry_options(*args)
    end

    def qry(*args)
      klass.qry qry_options(*args)
    end

    alias :original_count :count

    def count(column_name = nil, options = {})
      if !loaded? && (column_name == :all) && (options == {})
        qry("COUNT(DISTINCT id)")[0][0]
      else
        original_count column_name, options
      end
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
directiverecord-0.1.15 lib/directive_record/gem_ext/active_record/relation.rb
directiverecord-0.1.14 lib/directive_record/gem_ext/active_record/relation.rb
directiverecord-0.1.13 lib/directive_record/gem_ext/active_record/relation.rb
directiverecord-0.1.12 lib/directive_record/gem_ext/active_record/relation.rb
directiverecord-0.1.11 lib/directive_record/gem_ext/active_record/relation.rb