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
41
|
# File 'lib/action_blocks/data_engine/filter_engine.rb', line 16
def process
@root_table = @root_klass.arel_table
@root_key = @root_klass.to_s.underscore.to_sym
@tables[@root_key.to_sym] = @root_table
[@filter_reqs].flatten.each do |matchreq|
node, *rest = matchreq[:path1]
base_expression = walk_filter_path(@root_klass, node, @root_key, rest)
node, *rest = matchreq[:path2]
related_expression = walk_filter_path(@root_klass, node, @root_key, rest)
if base_expression.class.ancestors.include?(Arel::Attributes::Attribute)
where = base_expression.send(matchreq[:predicate], related_expression)
else
where = related_expression.send(matchreq[:predicate], base_expression)
end
@wheres << where
end
end
|