class Cql::Client::ExecuteOptionsDecoder

@private

Public Class Methods

new(default_consistency) click to toggle source
# File lib/cql/client/execute_options_decoder.rb, line 7
def initialize(default_consistency)
  @default_consistency = default_consistency
  @default_options = {:consistency => @default_consistency}.freeze
end

Public Instance Methods

decode_options(*args) click to toggle source
# File lib/cql/client/execute_options_decoder.rb, line 12
def decode_options(*args)
  if args.empty?
    @default_options
  elsif args.size == 1
    decode_one(args.first)
  else
    args.each_with_object({}) do |options_or_consistency, result|
      result.merge!(decode_one(options_or_consistency))
    end
  end
end

Private Instance Methods

decode_one(options_or_consistency) click to toggle source
# File lib/cql/client/execute_options_decoder.rb, line 26
def decode_one(options_or_consistency)
  return @default_options unless options_or_consistency
  case options_or_consistency
  when Symbol
    {:consistency => options_or_consistency}
  when Hash
    if options_or_consistency.include?(:consistency)
      options_or_consistency
    else
      options = options_or_consistency.dup
      options[:consistency] = @default_consistency
      options
    end
  end
end