Module: FreshConnection::Extend::ArBase
- Defined in:
- lib/fresh_connection/extend/ar_base.rb
Instance Method Summary collapse
- #clear_all_slave_connections! ⇒ Object
- #connection ⇒ Object
- #establish_fresh_connection(slave_group = nil) ⇒ Object
- #master_db_only! ⇒ Object
- #master_db_only? ⇒ Boolean
- #read_master ⇒ Object
- #slave_connection ⇒ Object
- #slave_connection_put_aside! ⇒ Object
- #slave_connection_recovery? ⇒ Boolean
- #slave_group ⇒ Object
- #with_master(&block) ⇒ Object
Instance Method Details
#clear_all_slave_connections! ⇒ Object
32 33 34 |
# File 'lib/fresh_connection/extend/ar_base.rb', line 32 def clear_all_slave_connections! slave_connection_handler.clear_all_connections! end |
#connection ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/fresh_connection/extend/ar_base.rb', line 4 def connection if FreshConnection::AccessControl.slave_access? if logger && logger.debug? slave_connection.tap{|c| c.slave_group = slave_group } else slave_connection end else super end end |
#establish_fresh_connection(slave_group = nil) ⇒ Object
24 25 26 |
# File 'lib/fresh_connection/extend/ar_base.rb', line 24 def establish_fresh_connection(slave_group = nil) slave_connection_handler.establish_connection(name, slave_group) end |
#master_db_only! ⇒ Object
36 37 38 |
# File 'lib/fresh_connection/extend/ar_base.rb', line 36 def master_db_only! @_fresh_connection_master_only = true end |
#master_db_only? ⇒ Boolean
40 41 42 43 |
# File 'lib/fresh_connection/extend/ar_base.rb', line 40 def master_db_only? @_fresh_connection_master_only ||= (self != ActiveRecord::Base && superclass.master_db_only?) end |
#read_master ⇒ Object
16 17 18 |
# File 'lib/fresh_connection/extend/ar_base.rb', line 16 def read_master all.read_master end |
#slave_connection ⇒ Object
28 29 30 |
# File 'lib/fresh_connection/extend/ar_base.rb', line 28 def slave_connection slave_connection_handler.connection(self) end |
#slave_connection_put_aside! ⇒ Object
45 46 47 |
# File 'lib/fresh_connection/extend/ar_base.rb', line 45 def slave_connection_put_aside! slave_connection_handler.put_aside! end |
#slave_connection_recovery? ⇒ Boolean
49 50 51 |
# File 'lib/fresh_connection/extend/ar_base.rb', line 49 def slave_connection_recovery? slave_connection_handler.recovery?(self) end |
#slave_group ⇒ Object
53 54 55 |
# File 'lib/fresh_connection/extend/ar_base.rb', line 53 def slave_group slave_connection_handler.slave_group(self) end |
#with_master(&block) ⇒ Object
20 21 22 |
# File 'lib/fresh_connection/extend/ar_base.rb', line 20 def with_master(&block) all.manage_access(false, &block) end |