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:



562
563
564
565
566
# File 'lib/redis.rb', line 562

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

Instance Method Details

#bool(name) ⇒ Object



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

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

#insert(name) ⇒ Object



592
593
594
# File 'lib/redis.rb', line 592

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

#multi(name) ⇒ Object



580
581
582
# File 'lib/redis.rb', line 580

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

#splat(name) ⇒ Object



576
577
578
# File 'lib/redis.rb', line 576

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

#to_aObject



588
589
590
# File 'lib/redis.rb', line 588

def to_a
  @result
end

#value(name) ⇒ Object



572
573
574
# File 'lib/redis.rb', line 572

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

#words(name) ⇒ Object



584
585
586
# File 'lib/redis.rb', line 584

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