Class: EY::Snaplock::Database
- Inherits:
-
Object
- Object
- EY::Snaplock::Database
show all
- Defined in:
- lib/ey_snaplock/database.rb,
lib/ey_snaplock/database/mysql.rb,
lib/ey_snaplock/database/postgresql9.rb
Defined Under Namespace
Classes: MySQL, Postgresql
Class Method Summary
collapse
Class Method Details
.for(database_uri) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/ey_snaplock/database.rb', line 7
def self.for(database_uri)
uri = parse_uri(database_uri)
case uri.scheme
when 'mysql'
MySQL.new(uri)
when "postgres9"
Postgresql.new(uri)
else
abort "Don't know how to lock database with URI: #{database_uri.inspect}"
end
end
|
.parse_uri(uri) ⇒ Object
23
24
25
26
27
28
29
30
|
# File 'lib/ey_snaplock/database.rb', line 23
def self.parse_uri(uri)
begin
Addressable::URI.parse(uri)
rescue TypeError, Addressable::URI::InvalidURIError
$stderr.puts "Error parsing database URI: #{uri.inspect}"
raise
end
end
|