Sha256: db96004d6640540c68c97a1894d33080d75260a5225620603f6a4d62b3f253d6

Contents?: true

Size: 733 Bytes

Versions: 1

Compression:

Stored size: 733 Bytes

Contents

require 'oxblood/commands'
require 'oxblood/protocol'

module Oxblood
  # Implements usual Request/Response protocol.
  # Error responses will be raised.
  #
  # @note {Session} don't maintain threadsafety! In multithreaded environment
  #   please use {Pool}
  #
  # @example
  #   conn = Oxblood::Connection.new
  #   session = Oxblood::Session.new(conn)
  #   session.ping # => 'PONG'
  class Session
    include Oxblood::Commands

    def initialize(connection)
      @connection = connection
    end

    private

    def run(*command)
      response = @connection.run_command(*command)
      error?(response) ? (raise response) : response
    end

    def error?(response)
      Protocol::RError === response
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
oxblood-0.1.0.dev9 lib/oxblood/session.rb