lib/mock_redis/stream.rb in mock_redis-0.25.0 vs lib/mock_redis/stream.rb in mock_redis-0.26.0
- old
+ new
@@ -58,12 +58,15 @@
items.reverse! if reversed
return items.first(opts['count'].to_i) if opts.key?('count')
items
end
- def read(id)
+ def read(id, *opts_in)
+ opts = options opts_in, %w[count block]
stream_id = MockRedis::Stream::Id.new(id)
- members.select { |m| (stream_id < m[0]) }.map { |m| [m[0].to_s, m[1]] }
+ items = members.select { |m| (stream_id < m[0]) }.map { |m| [m[0].to_s, m[1]] }
+ return items.first(opts['count'].to_i) if opts.key?('count')
+ items
end
def each
members.each { |m| yield m }
end