Sha256: 395de93c9c80507f65e276a678984e9572ba902a7ab502d02867f86f0b5f8700

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

module Boris
  class Connector
    include Lumberjack

    attr_reader :connected
    attr_reader :host
    attr_reader :options
    attr_reader :reconnectable

    def initialize(host, cred, options, logger=nil)
      debug 'creating connection object'

      @host = host
      @user = cred[:user]
      @password = cred[:password]
      @connected = false
      @reconnectable = true

      @logger = logger
    end

    def connected?
      @connected
    end

    def disconnect
      debug 'closing connection to host'
      @connected = false
    end

    def establish_connection
      debug 'attempting connection'
    end

    def values_at(request, limit)
      if !limit.kind_of?(Integer)
        raise ArgumentError, "non-integer limit specified (#{limit.inspect})"
      elsif limit < 1
        raise ArgumentError, "specified limit must be greater than 1 (or nil for no limit) (#{limit.inspect})"
      end unless limit.nil?

      amount = limit == 1 ? 'single value' : 'multiple values'

      debug "issuing request for #{amount} (#{request.inspect})"
    end
  end
end

Version data entries

2 entries across 1 versions & 1 rubygems

Version Path
boris-1.0.0.beta.1 ./lib/boris/connectors.rb
boris-1.0.0.beta.1 lib/boris/connectors.rb