Method: Predicate::ToSequel::Methods#on_match

Defined in:
lib/predicate/sequel/to_sequel.rb

#on_match(sexpr) ⇒ Object



95
96
97
98
99
100
101
102
103
104
105
# File 'lib/predicate/sequel/to_sequel.rb', line 95

def on_match(sexpr)
  left, right = sexpr.left, sexpr.right
  left  = [ left.first,  "%#{left.last}%"  ] if left.first  == :literal && !left.last.is_a?(Regexp)
  right = [ right.first, "%#{right.last}%" ] if right.first == :literal && !right.last.is_a?(Regexp)
  left, right = apply(left), apply(right)
  if sexpr.case_sentitive?
    left.like(right)
  else
    left.ilike(right)
  end
end