Sha256: 0ddcbee4567d732c797022f7a1325624ee289944929eae7a530a69af0fc35765
Contents?: true
Size: 936 Bytes
Versions: 1
Compression:
Stored size: 936 Bytes
Contents
REDIS_PORT = 6381 REDIS_OPTIONS = { :port => REDIS_PORT, :db => 14, :timeout => Float(ENV["TIMEOUT"] || 0.1), } class RedisMultiplex < Struct.new(:source, :destination) ResponseError = Class.new(RuntimeError) def ensure_same!(&blk) responses = { source: capture_result(source, &blk), destination: capture_result(destination, &blk) } unless responses[:source] == responses[:destination] raise ResponseError.new(responses.to_s) end case responses[:destination].first when :raised then raise responses[:destination].last when :returned then return responses[:destination].last end end alias_method :both!, :ensure_same! def both(&blk) both!(&blk) true rescue ResponseError false end def capture_result(redis, &block) return [:returned, block.call(redis)] rescue Object => exception return [:raised, exception] end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
redis-copy-0.0.6 | spec/spec_helper.rb |