lib/moped/connection.rb in moped-2.0.5 vs lib/moped/connection.rb in moped-2.0.6
- old
+ new
@@ -1,11 +1,10 @@
# encoding: utf-8
require "moped/connection/manager"
require "moped/connection/sockets"
module Moped
-
# This class contains behaviour of database socket connections.
#
# @since 2.0.0
class Connection
include Authenticatable
@@ -13,10 +12,12 @@
# The default connection timeout, in seconds.
#
# @since 2.0.0
TIMEOUT = 5
+ REPLY_DECODE_STR = 'l<5q<l<2'
+
# @!attribute host
# @return [ String ] The ip address of the host.
# @!attribute options
# @return [ Hash ] The connection options.
# @!attribute port
@@ -112,18 +113,18 @@
# @since 1.0.0
def read
with_connection do |socket|
reply = Protocol::Reply.allocate
data = read_data(socket, 36)
- response = data.unpack('l<5q<l<2')
+ response = data.unpack(REPLY_DECODE_STR)
reply.length,
- reply.request_id,
- reply.response_to,
- reply.op_code,
- reply.flags,
- reply.cursor_id,
- reply.offset,
- reply.count = response
+ reply.request_id,
+ reply.response_to,
+ reply.op_code,
+ reply.flags,
+ reply.cursor_id,
+ reply.offset,
+ reply.count = response
if reply.count == 0
reply.documents = []
else
sock_read = read_data(socket, reply.length - 36)