Class: Torque::PostgreSQL::PredicateBuilder::ArelAttributeHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/torque/postgresql/predicate_builder/arel_attribute_handler.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeArelAttributeHandler

Returns a new instance of ArelAttributeHandler.



12
13
14
# File 'lib/torque/postgresql/predicate_builder/arel_attribute_handler.rb', line 12

def initialize(*)
  # There is no need to use or save the predicate builder here
end

Class Method Details

.call(*args) ⇒ Object

Shortcut



8
9
10
# File 'lib/torque/postgresql/predicate_builder/arel_attribute_handler.rb', line 8

def self.call(*args)
  new.call(*args)
end

Instance Method Details

#call(attribute, value) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/torque/postgresql/predicate_builder/arel_attribute_handler.rb', line 16

def call(attribute, value)
  case
  when array_typed?(attribute) && array_typed?(value) then attribute.overlaps(value)
  when array_typed?(attribute) then value.eq(FN.any(attribute))
  when array_typed?(value) then attribute.eq(FN.any(value))
  else attribute.eq(value)
  end
end