Module: RCI::Commands
- Defined in:
- lib/rci/commands.rb
Defined Under Namespace
Classes: Command
Constant Summary collapse
- COMMANDS_WITH_SUBCOMMANDS =
As of Redis 3.0 there isn’t any indication from the COMMAND return info as to which commands accept a subcommand so we’re tracking them here
%i{client cluster command debug script}.to_set.freeze
Class Attribute Summary collapse
-
.commands ⇒ Object
readonly
Returns the value of attribute commands.
-
.read_command_names ⇒ Object
readonly
Returns the value of attribute read_command_names.
-
.read_commands ⇒ Object
readonly
Returns the value of attribute read_commands.
Class Method Summary collapse
- .command_type(command_array) ⇒ Object
- .discover!(client) ⇒ Object
- .extract_command(command_array) ⇒ Object
Class Attribute Details
.commands ⇒ Object (readonly)
Returns the value of attribute commands.
6 7 8 |
# File 'lib/rci/commands.rb', line 6 def commands @commands end |
.read_command_names ⇒ Object (readonly)
Returns the value of attribute read_command_names.
6 7 8 |
# File 'lib/rci/commands.rb', line 6 def read_command_names @read_command_names end |
.read_commands ⇒ Object (readonly)
Returns the value of attribute read_commands.
6 7 8 |
# File 'lib/rci/commands.rb', line 6 def read_commands @read_commands end |
Class Method Details
.command_type(command_array) ⇒ Object
17 18 19 |
# File 'lib/rci/commands.rb', line 17 def self.command_type(command_array) @read_command_names.include?(command_array.first) ? :read : :write end |
.discover!(client) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rci/commands.rb', line 21 def self.discover!(client) return @commands if @commands @commands = client.command.map{ |command_description| command_name = command_description.shift.to_sym Command.new(command_name, *command_description) } @read_commands = @commands.select { |command| command.flags.include?('readonly') } @read_command_names = @read_commands.map(&:name).to_set @commands end |
.extract_command(command_array) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/rci/commands.rb', line 32 def self.extract_command(command_array) command = command_array[0] info = {command: command} if COMMANDS_WITH_SUBCOMMANDS.include?(command) subcommand = command_array[1] info[:subcommand] = subcommand unless subcommand.nil? end info end |