Module: ActiveRecordExtended::ArrayHandlerDecorator

Defined in:
lib/active_record_extended/predicate_builder/array_handler_decorator.rb

Instance Method Summary collapse

Instance Method Details

#call(attribute, value) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/active_record_extended/predicate_builder/array_handler_decorator.rb', line 8

def call(attribute, value)
  cache = ActiveRecord::Base.connection.schema_cache
  if cache.data_source_exists?(attribute.relation.name)
    column = cache.columns(attribute.relation.name).detect { |col| col.name.to_s == attribute.name.to_s }
    return attribute.eq(value) if column.try(:array)
  end

  super(attribute, value)
end