File: command_executor.rb

package info (click to toggle)
ruby-fakeredis 0.8.0-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 628 kB
  • sloc: ruby: 4,868; makefile: 2
file content (22 lines) | stat: -rw-r--r-- 588 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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

      replies << reply
      nil
    end
  end
end