Class: FreshConnection::SlaveConnection
- Inherits:
-
Object
- Object
- FreshConnection::SlaveConnection
- Defined in:
- lib/fresh_connection/slave_connection.rb
Class Attribute Summary collapse
-
.ignore_configure_connection ⇒ Object
writeonly
Sets the attribute ignore_configure_connection.
-
.ignore_models ⇒ Object
writeonly
Sets the attribute ignore_models.
-
.master_clear_connection ⇒ Object
writeonly
Sets the attribute master_clear_connection.
Class Method Summary collapse
- .clear_all_connections! ⇒ Object
- .connection ⇒ Object
- .ignore_configure_connection? ⇒ Boolean
- .ignore_model?(model_name) ⇒ Boolean
- .master_clear_connection? ⇒ Boolean
- .slave_access? ⇒ Boolean
- .slave_access_in ⇒ Object
- .slave_access_out ⇒ Object
Class Attribute Details
.ignore_configure_connection=(value) ⇒ Object (writeonly)
Sets the attribute ignore_configure_connection
4 5 6 |
# File 'lib/fresh_connection/slave_connection.rb', line 4 def ignore_configure_connection=(value) @ignore_configure_connection = value end |
.ignore_models=(value) ⇒ Object (writeonly)
Sets the attribute ignore_models
4 5 6 |
# File 'lib/fresh_connection/slave_connection.rb', line 4 def ignore_models=(value) @ignore_models = value end |
.master_clear_connection=(value) ⇒ Object (writeonly)
Sets the attribute master_clear_connection
4 5 6 |
# File 'lib/fresh_connection/slave_connection.rb', line 4 def master_clear_connection=(value) @master_clear_connection = value end |
Class Method Details
.clear_all_connections! ⇒ Object
10 11 12 13 14 15 |
# File 'lib/fresh_connection/slave_connection.rb', line 10 def clear_all_connections! if @slave_connections.present? @slave_connections.each_value{|c| c && c.disconnect! rescue nil} end @slave_connections = {} end |
.connection ⇒ Object
6 7 8 |
# File 'lib/fresh_connection/slave_connection.rb', line 6 def connection slave_connection end |
.ignore_configure_connection? ⇒ Boolean
33 34 35 |
# File 'lib/fresh_connection/slave_connection.rb', line 33 def ignore_configure_connection? !!@ignore_configure_connection end |
.ignore_model?(model_name) ⇒ Boolean
29 30 31 |
# File 'lib/fresh_connection/slave_connection.rb', line 29 def ignore_model?(model_name) (@ignore_models || []).include?(model_name) end |
.master_clear_connection? ⇒ Boolean
37 38 39 |
# File 'lib/fresh_connection/slave_connection.rb', line 37 def master_clear_connection? @master_clear_connection.nil? || @master_clear_connection end |
.slave_access? ⇒ Boolean
25 26 27 |
# File 'lib/fresh_connection/slave_connection.rb', line 25 def slave_access? Thread.current[:fresh_connection_slave_access] ||= false end |
.slave_access_in ⇒ Object
17 18 19 |
# File 'lib/fresh_connection/slave_connection.rb', line 17 def slave_access_in Thread.current[:fresh_connection_slave_access] = true end |
.slave_access_out ⇒ Object
21 22 23 |
# File 'lib/fresh_connection/slave_connection.rb', line 21 def slave_access_out Thread.current[:fresh_connection_slave_access] = false end |