Class: Sybase::Client
- Inherits:
-
Object
- Object
- Sybase::Client
- Defined in:
- lib/sybase/client.rb
Defined Under Namespace
Classes: Messages, ResultBuilder
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#messages ⇒ Object
readonly
Returns the value of attribute messages.
Instance Method Summary collapse
- #close ⇒ Object
- #execute(sql) ⇒ Object
-
#initialize(db, opts = {}) ⇒ Client
constructor
Create a new client for the given database name.
Constructor Details
#initialize(db, opts = {}) ⇒ Client
Create a new client for the given database name
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/sybase/client.rb', line 10 def initialize(db, opts = {}) @context = Context.new @messages = Messages.new # TODO: listener? @context.callbacks.library { |msg| @messages. :library, msg } @context.callbacks.client { |msg| @messages. :client, msg } @context.callbacks.server { |msg| @messages. :server, msg } @connection = Connection.new(@context, :username => opts.fetch(:username) { raise ArgumentError, "no :username given" }, :password => opts.fetch(:password) { raise ArgumentError, "no :password given" }, :appname => opts.fetch(:appname) { "#{self.class} #{RUBY_DESCRIPTION}" }, :hostname => opts.fetch(:hostname) { Socket.gethostname } ) @connection.connect db.to_s if block_given? begin yield self ensure close end end end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
4 5 6 |
# File 'lib/sybase/client.rb', line 4 def connection @connection end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
4 5 6 |
# File 'lib/sybase/client.rb', line 4 def context @context end |
#messages ⇒ Object (readonly)
Returns the value of attribute messages.
4 5 6 |
# File 'lib/sybase/client.rb', line 4 def @messages end |
Instance Method Details
#close ⇒ Object
42 43 44 45 |
# File 'lib/sybase/client.rb', line 42 def close @connection.close if @connection @context.exit end |