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

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.

Instance Method Summary collapse

Constructor Details

#initialize(bindings) ⇒ QueryVisitor

Returns a new instance of QueryVisitor.



79
80
81
82
83
# File 'lib/record_cache/datastore/active_record_30.rb', line 79

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

Instance Method Details

#accept(object) ⇒ Object



85
86
87
88
# File 'lib/record_cache/datastore/active_record_30.rb', line 85

def accept object
  super
  @cacheable ? @query : nil
end