Module: FreshConnection::Extend::ArBase
- Defined in:
- lib/fresh_connection/extend/ar_base.rb
Instance Method Summary collapse
- #clear_all_replica_connections! ⇒ Object
- #clear_all_slave_connections! ⇒ Object
- #connection ⇒ Object
- #establish_fresh_connection(replica_group = nil) ⇒ Object
- #master_db_only! ⇒ Object
- #master_db_only? ⇒ Boolean
- #read_master ⇒ Object
- #replica_connection ⇒ Object
- #replica_connection_put_aside! ⇒ Object
- #replica_connection_recovery? ⇒ Boolean
- #replica_group ⇒ 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_replica_connections! ⇒ Object
44 45 46 |
# File 'lib/fresh_connection/extend/ar_base.rb', line 44 def clear_all_replica_connections! replica_connection_handler.clear_all_connections! end |
#clear_all_slave_connections! ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/fresh_connection/extend/ar_base.rb', line 48 def clear_all_slave_connections! ActiveSupport::Deprecation.warn( "'clear_all_slave_connections!' is deprecated and will removed from version 2.4.0. use 'clear_all_replica_connections!' insted." ) clear_all_replica_connections! end |
#connection ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/fresh_connection/extend/ar_base.rb', line 8 def connection if FreshConnection::AccessControl.replica_access? if logger && logger.debug? replica_connection.tap{|c| c.replica_group = replica_group } else replica_connection end else super end end |
#establish_fresh_connection(replica_group = nil) ⇒ Object
28 29 30 |
# File 'lib/fresh_connection/extend/ar_base.rb', line 28 def establish_fresh_connection(replica_group = nil) replica_connection_handler.establish_connection(name, replica_group) end |
#master_db_only! ⇒ Object
56 57 58 |
# File 'lib/fresh_connection/extend/ar_base.rb', line 56 def master_db_only! @_fresh_connection_master_only = true end |
#master_db_only? ⇒ Boolean
60 61 62 63 |
# File 'lib/fresh_connection/extend/ar_base.rb', line 60 def master_db_only? @_fresh_connection_master_only ||= (self != ActiveRecord::Base && superclass.master_db_only?) end |
#read_master ⇒ Object
20 21 22 |
# File 'lib/fresh_connection/extend/ar_base.rb', line 20 def read_master all.read_master end |
#replica_connection ⇒ Object
32 33 34 |
# File 'lib/fresh_connection/extend/ar_base.rb', line 32 def replica_connection replica_connection_handler.connection(self) end |
#replica_connection_put_aside! ⇒ Object
65 66 67 |
# File 'lib/fresh_connection/extend/ar_base.rb', line 65 def replica_connection_put_aside! replica_connection_handler.put_aside! end |
#replica_connection_recovery? ⇒ Boolean
77 78 79 |
# File 'lib/fresh_connection/extend/ar_base.rb', line 77 def replica_connection_recovery? replica_connection_handler.recovery?(self) end |
#replica_group ⇒ Object
89 90 91 |
# File 'lib/fresh_connection/extend/ar_base.rb', line 89 def replica_group replica_connection_handler.replica_group(self) end |
#slave_connection ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/fresh_connection/extend/ar_base.rb', line 36 def slave_connection ActiveSupport::Deprecation.warn( "'slave_connection' is deprecated and will removed from version 2.4.0. use 'replica_connection' insted." ) replica_connection end |
#slave_connection_put_aside! ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/fresh_connection/extend/ar_base.rb', line 69 def slave_connection_put_aside! ActiveSupport::Deprecation.warn( "'slave_connection_put_aside!' is deprecated and will removed from version 2.4.0. use 'replica_connection_put_aside!' insted." ) replica_connection_put_aside! end |
#slave_connection_recovery? ⇒ Boolean
81 82 83 84 85 86 87 |
# File 'lib/fresh_connection/extend/ar_base.rb', line 81 def slave_connection_recovery? ActiveSupport::Deprecation.warn( "'slave_connection_recovery?' is deprecated and will removed from version 2.4.0. use 'replica_connection_recovery?' insted." ) replica_connection_recovery? end |
#slave_group ⇒ Object
93 94 95 96 97 98 99 |
# File 'lib/fresh_connection/extend/ar_base.rb', line 93 def slave_group ActiveSupport::Deprecation.warn( "'slave_connection_recovery?' is deprecated and will removed from version 2.4.0. use 'replica_connection_recovery?' insted." ) replica_group end |
#with_master(&block) ⇒ Object
24 25 26 |
# File 'lib/fresh_connection/extend/ar_base.rb', line 24 def with_master(&block) all.manage_access(false, &block) end |