Class: Redis::CommandOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/redis.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) {|_self| ... } ⇒ CommandOptions

Returns a new instance of CommandOptions.

Yields:

  • (_self)

Yield Parameters:



1073
1074
1075
1076
1077
# File 'lib/redis.rb', line 1073

def initialize(options)
  @result = []
  @options = options
  yield(self)
end

Instance Method Details

#bool(name) ⇒ Object



1079
1080
1081
# File 'lib/redis.rb', line 1079

def bool(name)
  insert(name) { |argument, value| [argument] }
end

#insert(name) ⇒ Object



1103
1104
1105
# File 'lib/redis.rb', line 1103

def insert(name)
  @result += yield(name.to_s.upcase.gsub("_", ""), @options[name]) if @options[name]
end

#multi(name) ⇒ Object



1091
1092
1093
# File 'lib/redis.rb', line 1091

def multi(name)
  insert(name) { |argument, value| [argument].product(Array(value)).flatten }
end

#splat(name) ⇒ Object



1087
1088
1089
# File 'lib/redis.rb', line 1087

def splat(name)
  insert(name) { |argument, value| [argument, *value] }
end

#to_aObject



1099
1100
1101
# File 'lib/redis.rb', line 1099

def to_a
  @result
end

#value(name) ⇒ Object



1083
1084
1085
# File 'lib/redis.rb', line 1083

def value(name)
  insert(name) { |argument, value| [argument, value] }
end

#words(name) ⇒ Object



1095
1096
1097
# File 'lib/redis.rb', line 1095

def words(name)
  insert(name) { |argument, value| value.split(" ") }
end