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:



606
607
608
609
610
# File 'lib/redis.rb', line 606

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

Instance Method Details

#bool(name) ⇒ Object



612
613
614
# File 'lib/redis.rb', line 612

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

#insert(name) ⇒ Object



636
637
638
# File 'lib/redis.rb', line 636

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

#multi(name) ⇒ Object



624
625
626
# File 'lib/redis.rb', line 624

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

#splat(name) ⇒ Object



620
621
622
# File 'lib/redis.rb', line 620

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

#to_aObject



632
633
634
# File 'lib/redis.rb', line 632

def to_a
  @result
end

#value(name) ⇒ Object



616
617
618
# File 'lib/redis.rb', line 616

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

#words(name) ⇒ Object



628
629
630
# File 'lib/redis.rb', line 628

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