Class: Readyset::Caches

Inherits:
Object
  • Object
show all
Defined in:
lib/readyset/caches.rb

Overview

Defines the DSL used in the gem’s “migration” files. The DSL should be used by inheriting from this class and invoking the ‘.cache` class method to define new caches.

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.cachesObject (readonly)

Returns the value of attribute caches.



6
7
8
# File 'lib/readyset/caches.rb', line 6

def caches
  @caches
end

Class Method Details

.cache(always: false) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/readyset/caches.rb', line 9

def self.cache(always: false)
  @caches ||= Set.new

  query = yield

  @caches << Query::CachedQuery.new(
    text: query.strip,
    always: always,
  )
end