Sha256: e5b6fdb402934c4918ea4a93e562d1e54732323c0fdfbe9937143ae4c396f9e7

Contents?: true

Size: 685 Bytes

Versions: 2

Compression:

Stored size: 685 Bytes

Contents

module FakeRedis
  module CommandExecutor
    def write(command)
      meffod = command[0].to_s.downcase.to_sym
      args = command[1..-1]

      if in_multi && !(TRANSACTION_COMMANDS.include? meffod) # queue commands
        queued_commands << [meffod, *args]
        reply = 'QUEUED'
      elsif respond_to?(meffod) && method(meffod).arity.zero?
        reply = send(meffod)
      elsif respond_to?(meffod)
        reply = send(meffod, *args)
      else
        raise Redis::CommandError, "ERR unknown command '#{meffod}'"
      end

      if reply == true
        reply = 1
      elsif reply == false
        reply = 0
      end

      replies << reply
      nil
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
fakeredis-0.7.0 lib/fakeredis/command_executor.rb
kuende-fakeredis-0.10.0 lib/fakeredis/command_executor.rb