Module: RailsSimpleSearch::SqlHandler
- Defined in:
- lib/sql_handler.rb,
lib/selection_item.rb,
lib/selection_group.rb
Defined Under Namespace
Classes: SelectionGroup, SelectionItem
Instance Method Summary
collapse
Instance Method Details
#init ⇒ Object
38
39
40
41
|
# File 'lib/sql_handler.rb', line 38
def init
@model_table_name = @model_class.table_name
@joins = {}
end
|
#run ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/sql_handler.rb', line 43
def run
if pre_processor = self.class.pre_processor(@model_class.to_s)
instance_eval(&pre_processor)
end
selection_group = generate_selection_group(@criteria)
raw_sql = selection_group.to_sql
if raw_sql.blank?
@model_class.all
else
@model_class.from("(#{raw_sql}) AS #{@model_table_name}")
end
end
|