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.
6 7 8 9 10 11 12 13 |
# File 'lib/search_cop/query_builder.rb', line 6 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.
4 5 6 |
# File 'lib/search_cop/query_builder.rb', line 4 def query_info @query_info end |
#scope ⇒ Object
Returns the value of attribute scope.
4 5 6 |
# File 'lib/search_cop/query_builder.rb', line 4 def scope @scope end |
#sql ⇒ Object
Returns the value of attribute sql.
4 5 6 |
# File 'lib/search_cop/query_builder.rb', line 4 def sql @sql end |
Instance Method Details
#associations ⇒ Object
15 16 17 |
# File 'lib/search_cop/query_builder.rb', line 15 def associations all_associations - [query_info.model.name.tableize.to_sym] end |