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:



568
569
570
571
572
# File 'lib/redis.rb', line 568

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

Instance Method Details

#bool(name) ⇒ Object



574
575
576
# File 'lib/redis.rb', line 574

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

#insert(name) ⇒ Object



598
599
600
# File 'lib/redis.rb', line 598

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

#multi(name) ⇒ Object



586
587
588
# File 'lib/redis.rb', line 586

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

#splat(name) ⇒ Object



582
583
584
# File 'lib/redis.rb', line 582

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

#to_aObject



594
595
596
# File 'lib/redis.rb', line 594

def to_a
  @result
end

#value(name) ⇒ Object



578
579
580
# File 'lib/redis.rb', line 578

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

#words(name) ⇒ Object



590
591
592
# File 'lib/redis.rb', line 590

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