Module: FreshConnection::Extend::ArAbstractAdapter

Defined in:
lib/fresh_connection/extend/ar_abstract_adapter.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.prepended(base) ⇒ Object



4
5
6
7
# File 'lib/fresh_connection/extend/ar_abstract_adapter.rb', line 4

def self.prepended(base)
  base.send :attr_writer, :replica_group
  base.send :attr_accessor, :master_connection
end

Instance Method Details

#cache(&block) ⇒ Object



24
25
26
27
# File 'lib/fresh_connection/extend/ar_abstract_adapter.rb', line 24

def cache(&block)
  return super unless master_connection
  master_connection.cache(&block)
end

#clear_query_cacheObject



44
45
46
47
# File 'lib/fresh_connection/extend/ar_abstract_adapter.rb', line 44

def clear_query_cache
  return super unless master_connection
  master_conection.clear_query_cache
end

#disable_query_cache!Object



34
35
36
37
# File 'lib/fresh_connection/extend/ar_abstract_adapter.rb', line 34

def disable_query_cache!
  return super unless master_connection
  master_connection.disable_query_cache!
end

#enable_query_cache!Object



29
30
31
32
# File 'lib/fresh_connection/extend/ar_abstract_adapter.rb', line 29

def enable_query_cache!
  return super unless master_connection
  master_connection.enable_query_cache!
end

#log(*args) ⇒ Object



9
10
11
12
# File 'lib/fresh_connection/extend/ar_abstract_adapter.rb', line 9

def log(*args)
  args[1] = "[#{@replica_group}] #{args[1]}" if defined?(@replica_group)
  super
end

#query_cacheObject



14
15
16
17
# File 'lib/fresh_connection/extend/ar_abstract_adapter.rb', line 14

def query_cache
  return @query_cache unless master_connection
  master_connection.query_cache
end

#query_cache_enabledObject



19
20
21
22
# File 'lib/fresh_connection/extend/ar_abstract_adapter.rb', line 19

def query_cache_enabled
  return @query_cache_enabled unless master_connection
  master_connection.query_cache_enabled
end

#select_all(*args) ⇒ Object



49
50
51
52
53
# File 'lib/fresh_connection/extend/ar_abstract_adapter.rb', line 49

def select_all(*args)
  return super unless master_connection
  @query_cache_enabled = master_connection.query_cache_enabled
  super
end

#uncached(&block) ⇒ Object



39
40
41
42
# File 'lib/fresh_connection/extend/ar_abstract_adapter.rb', line 39

def uncached(&block)
  return super unless master_connection
  master_connection.uncached(&block)
end