Class: Mysql2xxxx::Properties

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Properties

Returns a new instance of Properties.



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

def initialize(options = {})
  @options = options.dup
  @options.stringify_keys!
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

Instance Method Details

#charsetObject

MySQL connection charset

If you change this, you also have to change :encoding

Default: utf8



26
27
28
# File 'lib/mysql2xxxx/properties.rb', line 26

def charset
  options['charset'] || 'utf8'
end

#databaseObject



47
48
49
# File 'lib/mysql2xxxx/properties.rb', line 47

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

#encodingObject

Encoding

If you change this, you also have to change :charset

Default: UTF-8



35
36
37
# File 'lib/mysql2xxxx/properties.rb', line 35

def encoding
  options['encoding'] || 'UTF-8'
end

#executeObject



51
52
53
# File 'lib/mysql2xxxx/properties.rb', line 51

def execute
  options['execute']
end

#hostObject



17
18
19
# File 'lib/mysql2xxxx/properties.rb', line 17

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

#passwordObject



13
14
15
# File 'lib/mysql2xxxx/properties.rb', line 13

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

#portObject



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

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

#socketObject



43
44
45
# File 'lib/mysql2xxxx/properties.rb', line 43

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

#userObject



9
10
11
# File 'lib/mysql2xxxx/properties.rb', line 9

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