Module: GlobalUid::ServerVariables

Defined in:
lib/global_uid/server_variables.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



13
14
15
16
# File 'lib/global_uid/server_variables.rb', line 13

def self.extended(base)
  base.singleton_class.send(:alias_method, :new_connection_without_server_variables, :new_connection)
  base.singleton_class.send(:alias_method, :new_connection, :new_connection_with_server_variables)
end

Instance Method Details

#new_connection_with_server_variables(name, connection_timeout, offset, increment_by) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/global_uid/server_variables.rb', line 18

def new_connection_with_server_variables(name, connection_timeout, offset, increment_by)
  con = new_connection_without_server_variables(name, connection_timeout, offset, increment_by)

  if con
    con.execute("set @@auto_increment_increment = #{increment_by}")
    con.execute("set @@auto_increment_offset = #{offset}")
  end

  con
end