Module: Torque::PostgreSQL::PredicateBuilder::ArrayHandler

Included in:
Associations::AssociationScope::PredicateBuilderArray
Defined in:
lib/torque/postgresql/predicate_builder/array_handler.rb

Instance Method Summary collapse

Instance Method Details

#call(attribute, value) ⇒ Object



7
8
9
10
11
12
# File 'lib/torque/postgresql/predicate_builder/array_handler.rb', line 7

def call(attribute, value)
  return super unless array_attribute?(attribute) &&
    PostgreSQL.config.predicate_builder.handle_array_attributes

  call_for_array(attribute, value)
end

#call_for_array(attribute, value) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/torque/postgresql/predicate_builder/array_handler.rb', line 14

def call_for_array(attribute, value)
  if !value.is_a?(::Array)
    call_with_value(attribute, value)
  elsif value.any?
    call_with_array(attribute, value)
  else
    call_with_empty(attribute)
  end
end