Class: Mysql2xxxx::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/mysql2xxxx/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Config

Returns a new instance of Config.



4
5
6
# File 'lib/mysql2xxxx/config.rb', line 4

def initialize(options = {})
  @options = options.symbolize_keys
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/mysql2xxxx/config.rb', line 3

def options
  @options
end

Instance Method Details

#databaseObject



28
29
30
# File 'lib/mysql2xxxx/config.rb', line 28

def database
  options[:database] || active_record_connection.try(:current_database)
end

#executeObject



32
33
34
# File 'lib/mysql2xxxx/config.rb', line 32

def execute
  options[:execute]
end

#hostObject



16
17
18
# File 'lib/mysql2xxxx/config.rb', line 16

def host
  options[:host] || active_record_config.try(:[], :host)
end

#passwordObject



12
13
14
# File 'lib/mysql2xxxx/config.rb', line 12

def password
  options[:password] || active_record_config.try(:[], :password)
end

#portObject



20
21
22
# File 'lib/mysql2xxxx/config.rb', line 20

def port
  options[:port] || active_record_config.try(:[], :port)
end

#slash_nObject

Whether to write N instead of a blank string for NULL. This is helpful for mysqlimport.

Only applies to CSV



39
40
41
# File 'lib/mysql2xxxx/config.rb', line 39

def slash_n
  options.fetch :slash_n, false
end

#socketObject



24
25
26
# File 'lib/mysql2xxxx/config.rb', line 24

def socket
  options[:socket] || active_record_config.try(:[], :socket)
end

#userObject



8
9
10
# File 'lib/mysql2xxxx/config.rb', line 8

def user
  options[:user] || active_record_config.try(:[], :username)
end