Sha256: 863076b71717e482c14571af64428256dcb91614e09832590a3d96b2495bb47c

Contents?: true

Size: 612 Bytes

Versions: 5

Compression:

Stored size: 612 Bytes

Contents

# frozen_string_literal: true
module Kasket
  module RelationMixin
    # binds can be removed when support for Rails < 5 is removed
    def to_kasket_query(binds = nil)
      if arel.is_a?(Arel::SelectManager)
        if ActiveRecord::VERSION::MAJOR < 5
          arel.to_kasket_query(klass, (binds || bind_values))
        elsif ActiveRecord::VERSION::STRING < '5.2'
          arel.to_kasket_query(klass, (@values[:where].to_h.values + Array(@values[:limit])))
        else
          arel.to_kasket_query(klass)
        end
      end
    rescue TypeError # unsupported object in ast
      nil
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
kasket-4.10.4 lib/kasket/relation_mixin.rb
kasket-4.10.2.1 lib/kasket/relation_mixin.rb
kasket-4.10.0 lib/kasket/relation_mixin.rb
kasket-4.9.1 lib/kasket/relation_mixin.rb
kasket-4.9.0 lib/kasket/relation_mixin.rb