Sha256: a8c05037d4f576e3f578b84014af9d97989e820776b17c37c1894841a6a73916
Contents?: true
Size: 1.37 KB
Versions: 2
Compression:
Stored size: 1.37 KB
Contents
module Alf module Sequel class Connection module ConnectionMethods def connection_uri(with_password = false) if conn_spec.is_a?(Hash) cs = Tuple(self.conn_spec) adapter, host, port, database, user, password = cs.values_at(:adapter, :host, :port, :database, :user, :password) user = "#{user}:#{password}" if user and password and with_password user = "#{user}@" if user host = "localhost" if host.nil? and not(adapter =~ /sqlite/) host = "#{host}:#{port}" if host and port host = "/#{user}#{host}" if host or user "#{adapter}:/#{host}/#{database}" elsif conn_spec.is_a?(String) conn_spec else "Alf::Sequel::Connection(#{conn_spec})" end end def ping sequel_db.test_connection end def close @sequel_db.disconnect if @sequel_db && @sequel_db != conn_spec end def with_sequel_db yield(sequel_db) end private # Yields a Sequel::Database object def sequel_db @sequel_db ||= Adapter.sequel_db(conn_spec) block_given? ? yield(@sequel_db) : @sequel_db end end # module ConnectionMethods end # module Connection end # module Sequel end # module Alf
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
alf-sequel-0.14.0 | lib/alf/sequel/connection/connection_methods.rb |
alf-sequel-0.13.0 | lib/alf/sequel/connection/connection_methods.rb |