Sha256: daae81325f5f6f37b9e8393d9ed4d847dc58f5d79e6e1d322af0381e4c5d0f38
Contents?: true
Size: 1.47 KB
Versions: 34
Compression:
Stored size: 1.47 KB
Contents
module FlydataCore module Postgresql class Config def self.build_db_opts(db_conf) db_opts = [:host, :port, :username, :password, :database, :dbname, :user, :connect_timeout, :sslmode, :options, ].inject({}) { |h, sym| if db_conf.has_key?(sym) h[sym] = db_conf[sym] elsif db_conf[sym.to_s] h[sym] = db_conf[sym.to_s] end h } # for pg gem update_opts(db_opts, :user, :username) update_opts(db_opts, :dbname, :database) db_opts end # Returns options for making pg connection # pg does not accept unsupported keys # http://www.rubydoc.info/gems/pg/PG%2FConnection%3Ainitialize def self.opts_for_pg(db_conf) db_opts = build_db_opts(db_conf) [:host, :port, :user, :password, :dbname, :connect_timeout, :sslmode, :options, ].inject({}) do |ret, k| ret[k] = db_opts[k] if db_opts[k] ret end end def self.update_opts(opts, dst_key, src_key) if opts[dst_key].nil? && opts[src_key] opts[dst_key] = opts[src_key] end end end end end
Version data entries
34 entries across 34 versions & 1 rubygems