Class: Appshot::Mysql

Inherits:
Object
  • Object
show all
Includes:
Methadone::CLILogging
Defined in:
lib/appshot/app/mysql.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Mysql

Returns a new instance of Mysql.



7
8
9
10
11
12
13
# File 'lib/appshot/app/mysql.rb', line 7

def initialize(opts={})
  @host = opts[:hostname] || "localhost"
  @name = opts[:name]     || "mysql"
  @port = opts[:port]     || 3306
  @user = opts[:username] || "mysql"
  @password = opts[:password]
end

Instance Method Details

#call(call_chain) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/appshot/app/mysql.rb', line 15

def call(call_chain)
  require 'mysql2'
  next_action = call_chain.shift
  @client = Mysql2::Client.new(username: @user, hostname: @host, password: @password, port: @port, database: @name)

  lock
  next_action.call(call_chain) unless next_action.nil?
ensure
  unlock
end