Class: RecordCache::Arel::QueryVisitor

Inherits:
Arel::Visitors::Visitor
  • Object
show all
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,
lib/record_cache/datastore/active_record_40.rb,
lib/record_cache/datastore/active_record_41.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

Constructor Details

#initialize(bindings) ⇒ QueryVisitor

Returns a new instance of QueryVisitor.



92
93
94
95
96
# File 'lib/record_cache/datastore/active_record_30.rb', line 92

def initialize
  super()
  @cacheable  = true
  @query = ::RecordCache::Query.new
end

Instance Method Details

#accept(ast) ⇒ Object



98
99
100
101
# File 'lib/record_cache/datastore/active_record_30.rb', line 98

def accept ast
  super
  @cacheable && !ast.lock ? @query : nil
end