lib/oxblood/pipeline.rb in oxblood-0.1.0.dev10 vs lib/oxblood/pipeline.rb in oxblood-0.1.0.dev11
- old
+ new
@@ -12,11 +12,11 @@
# pipeline.echo('ping')
# pipeline.ping
# pipeline.echo('!')
# pipeline.sync # => ["ping", "PONG", "!"]
class Pipeline
- include Oxblood::Commands
+ include Commands
attr_reader :connection
def initialize(connection)
@connection = connection
@@ -24,15 +24,12 @@
end
# Sends all commands at once and reads responses
# @return [Array] of responses
def sync
- serialized_commands = @commands.map do |c|
- Oxblood::Protocol.build_command(*c)
- end
-
- @connection.socket.write(serialized_commands.join)
- @connection.read_responses(@commands.size)
+ serialized_commands = @commands.map { |c| Protocol.build_command(*c) }
+ connection.socket.write(serialized_commands.join)
+ Array.new(@commands.size) { connection.read_response }
ensure
@commands.clear
end
private