Sha256: 7d68c47888a48f5dde5582ce499b69422180c507018ccba152eba832918d481b

Contents?: true

Size: 922 Bytes

Versions: 2

Compression:

Stored size: 922 Bytes

Contents

require 'active_record/relation/predicate_builder'
require 'active_record/relation/predicate_builder/array_handler'

require 'active_support/concern'

module ActiveRecord
  class PredicateBuilder
    module ArrayHandlerPatch
      extend ActiveSupport::Concern

      included do
        def call_with_feature(attribute, value)
          engine = attribute.relation.engine
          column = engine.connection.schema_cache.columns(attribute.relation.name).detect{ |col| col.name.to_s == attribute.name.to_s }
          if column && column.respond_to?(:array) && column.array
            attribute.eq(value)
          else
            call_without_feature(attribute, value)
          end
        end

        alias_method_chain(:call, :feature)
      end

      module ClassMethods

      end
    end
  end
end

ActiveRecord::PredicateBuilder::ArrayHandler.send(:include, ActiveRecord::PredicateBuilder::ArrayHandlerPatch)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
postgres_ext-3.0.0 lib/postgres_ext/active_record/relation/predicate_builder/array_handler.rb
postgres_ext-2.4.1 lib/postgres_ext/active_record/relation/predicate_builder/array_handler.rb