Class: SearchCop::QueryBuilder
- Inherits:
-
Object
- Object
- SearchCop::QueryBuilder
- Defined in:
- lib/search_cop/query_builder.rb
Instance Attribute Summary collapse
-
#query_info ⇒ Object
Returns the value of attribute query_info.
-
#scope ⇒ Object
Returns the value of attribute scope.
-
#sql ⇒ Object
Returns the value of attribute sql.
Instance Method Summary collapse
- #associations ⇒ Object
-
#initialize(model, query, scope, query_options) ⇒ QueryBuilder
constructor
A new instance of QueryBuilder.
Constructor Details
#initialize(model, query, scope, query_options) ⇒ QueryBuilder
Returns a new instance of QueryBuilder.
5 6 7 8 9 10 11 12 |
# File 'lib/search_cop/query_builder.rb', line 5 def initialize(model, query, scope, ) self.scope = scope self.query_info = QueryInfo.new(model, scope) arel = SearchCop::Parser.parse(query, query_info, ).optimize! self.sql = SearchCop::Visitors::Visitor.new(model.connection).visit(arel) end |
Instance Attribute Details
#query_info ⇒ Object
Returns the value of attribute query_info.
3 4 5 |
# File 'lib/search_cop/query_builder.rb', line 3 def query_info @query_info end |
#scope ⇒ Object
Returns the value of attribute scope.
3 4 5 |
# File 'lib/search_cop/query_builder.rb', line 3 def scope @scope end |
#sql ⇒ Object
Returns the value of attribute sql.
3 4 5 |
# File 'lib/search_cop/query_builder.rb', line 3 def sql @sql end |
Instance Method Details
#associations ⇒ Object
14 15 16 |
# File 'lib/search_cop/query_builder.rb', line 14 def associations all_associations - [query_info.model.name.tableize.to_sym] - [query_info.model.table_name.to_sym] end |