class Dossier::ConnectionUrl
Attributes
uri[R]
Public Class Methods
new(url = nil)
click to toggle source
# File lib/dossier/connection_url.rb, line 9 def initialize(url = nil) @uri = URI.parse(url || ENV.fetch('DATABASE_URL')) end
Public Instance Methods
to_hash()
click to toggle source
# File lib/dossier/connection_url.rb, line 13 def to_hash { adapter: adapter, username: uri.user, password: uri.password, host: uri.host, port: uri.port, database: File.basename(uri.path) }.merge(params).reject { |k,v| v.nil? } end
Private Instance Methods
adapter()
click to toggle source
# File lib/dossier/connection_url.rb, line 26 def adapter uri.scheme == "postgres" ? "postgresql" : uri.scheme end
params()
click to toggle source
# File lib/dossier/connection_url.rb, line 30 def params return {} unless uri.query Rack::Utils.parse_nested_query(uri.query).symbolize_keys end