class ORMakers::DBCredentials

Public Class Methods

new(url = ENV['DATABASE_URL']) click to toggle source
# File lib/ormakers/db_credentials.rb, line 3
def initialize(url = ENV['DATABASE_URL'])
  @url = url[11..-1]
end

Public Instance Methods

to_hash() click to toggle source
# File lib/ormakers/db_credentials.rb, line 7
def to_hash
  {
    host: host,
    port: port,
    dbname: dbname,
    user: user,
    password: password,
    sslmode: 'require'
  }
end

Private Instance Methods

dbname() click to toggle source
# File lib/ormakers/db_credentials.rb, line 28
def dbname
  @url.split('@').last.split('/').last
end
host() click to toggle source
# File lib/ormakers/db_credentials.rb, line 32
def host
  @url.split('@').last.split('/').first.split(':').first
end
password() click to toggle source
# File lib/ormakers/db_credentials.rb, line 24
def password
  @url.split('@').first.split(':').last
end
port() click to toggle source
# File lib/ormakers/db_credentials.rb, line 36
def port
  @url.split('@').last.split('/').first.split(':').last
end
user() click to toggle source
# File lib/ormakers/db_credentials.rb, line 20
def user
  @url.split('@').first.split(':').first
end