Class: RailsSimpleSearch::SqlHandler::SelectionItem
- Inherits:
-
Object
- Object
- RailsSimpleSearch::SqlHandler::SelectionItem
- Defined in:
- lib/selection_item.rb
Overview
this class represents a single select statement, without unions or intersects.
Instance Attribute Summary collapse
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(config, model_class, field, value) ⇒ SelectionItem
constructor
A new instance of SelectionItem.
- #to_sql ⇒ Object
Constructor Details
#initialize(config, model_class, field, value) ⇒ SelectionItem
Returns a new instance of SelectionItem.
8 9 10 11 12 13 14 15 |
# File 'lib/selection_item.rb', line 8 def initialize(config, model_class, field, value) @config = config @model_class = model_class @field = field @value = value @joins = {} @verb = '' end |
Instance Attribute Details
#field ⇒ Object (readonly)
Returns the value of attribute field.
6 7 8 |
# File 'lib/selection_item.rb', line 6 def field @field end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
6 7 8 |
# File 'lib/selection_item.rb', line 6 def value @value end |
Instance Method Details
#to_sql ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/selection_item.rb', line 17 def to_sql build_select_with_condition(@field, @value) join_str = make_joins query = @model_class.joins(join_str) query = query.where(to_ar_condition) query = query.select("distinct #{@model_class.table_name}.*") query.to_sql end |