Sha256: a3759775ccdf063e0b711ee1a6cfefec384bedbd59675fc472fd998660f17621
Contents?: true
Size: 955 Bytes
Versions: 3
Compression:
Stored size: 955 Bytes
Contents
# encoding: utf-8 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
redis-copy-1.0.0 | spec/spec_helper.rb |
redis-copy-1.0.0.rc.1 | spec/spec_helper.rb |
redis-copy-1.0.0.rc.0 | spec/spec_helper.rb |