12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/active_record/refinements.rb', line 12
def where(opts = nil, *rest, &block)
if block
col, op, val = Module.new { using ActiveRecord::Refinements::WhereBlockSyntax }.module_eval &block
arel_node = case op
when :==
table[col].eq val
when :!=
table[col].not_eq val
when :=~
table[col].matches val
when :>
table[col].gt val
when :>=
table[col].gteq val
when :<
table[col].lt val
when :<=
table[col].lteq val
else
raise "unexpected op: #{op}"
end
clone.tap do |relation|
relation.where_values += build_where(arel_node)
end
else
super
end
end
|