Class: RecordCache::Arel::QueryVisitor
- Inherits:
-
Arel::Visitors::Visitor
- Object
- Arel::Visitors::Visitor
- RecordCache::Arel::QueryVisitor
- Defined in:
- lib/record_cache/datastore/active_record_30.rb,
lib/record_cache/datastore/active_record_31.rb,
lib/record_cache/datastore/active_record_32.rb
Overview
Visitor for the ActiveRelation to extract a simple cache query Only accepts single select queries with equality where statements Rejects queries with grouping / having / offset / etc.
Constant Summary collapse
- DESC =
"DESC".freeze
- COMMA =
",".freeze
Instance Method Summary collapse
- #accept(ast) ⇒ Object
-
#initialize(bindings) ⇒ QueryVisitor
constructor
A new instance of QueryVisitor.
Constructor Details
#initialize(bindings) ⇒ QueryVisitor
Returns a new instance of QueryVisitor.
93 94 95 96 97 |
# File 'lib/record_cache/datastore/active_record_30.rb', line 93 def initialize super() @cacheable = true @query = ::RecordCache::Query.new end |
Instance Method Details
#accept(ast) ⇒ Object
99 100 101 102 |
# File 'lib/record_cache/datastore/active_record_30.rb', line 99 def accept ast super @cacheable && !ast.lock ? @query : nil end |