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:



519
520
521
522
523
# File 'lib/redis.rb', line 519

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

Instance Method Details

#bool(name) ⇒ Object



525
526
527
# File 'lib/redis.rb', line 525

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

#insert(name) ⇒ Object



549
550
551
# File 'lib/redis.rb', line 549

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

#multi(name) ⇒ Object



537
538
539
# File 'lib/redis.rb', line 537

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

#splat(name) ⇒ Object



533
534
535
# File 'lib/redis.rb', line 533

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

#to_aObject



545
546
547
# File 'lib/redis.rb', line 545

def to_a
  @result
end

#value(name) ⇒ Object



529
530
531
# File 'lib/redis.rb', line 529

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

#words(name) ⇒ Object



541
542
543
# File 'lib/redis.rb', line 541

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