Class: FreshConnection::SlaveConnection

Inherits:
Object
  • Object
show all
Defined in:
lib/fresh_connection/slave_connection.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.ignore_configure_connection=(value) ⇒ Object (writeonly)

Sets the attribute ignore_configure_connection

Parameters:

  • value

    the value to set the attribute ignore_configure_connection to.



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

Parameters:

  • value

    the value to set the attribute ignore_models to.



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

Parameters:

  • value

    the value to set the attribute master_clear_connection to.



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

.connectionObject



6
7
8
# File 'lib/fresh_connection/slave_connection.rb', line 6

def connection
  slave_connection
end

.ignore_configure_connection?Boolean

Returns:

  • (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

Returns:

  • (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

Returns:

  • (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

Returns:

  • (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_inObject



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_outObject



21
22
23
# File 'lib/fresh_connection/slave_connection.rb', line 21

def slave_access_out
  Thread.current[:fresh_connection_slave_access] = false
end