Class: Cql::Client::ExecuteOptionsDecoder

Inherits:
Object
  • Object
show all
Defined in:
lib/cql/client/execute_options_decoder.rb

Instance Method Summary collapse

Constructor Details

#initialize(default_consistency) ⇒ ExecuteOptionsDecoder

Returns a new instance of ExecuteOptionsDecoder.



7
8
9
# File 'lib/cql/client/execute_options_decoder.rb', line 7

def initialize(default_consistency)
  @default_consistency = default_consistency
end

Instance Method Details

#decode_options(options_or_consistency) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/cql/client/execute_options_decoder.rb', line 11

def decode_options(options_or_consistency)
  consistency = @default_consistency
  timeout = nil
  trace = false
  case options_or_consistency
  when Symbol
    consistency = options_or_consistency
  when Hash
    consistency = options_or_consistency[:consistency] || consistency
    timeout = options_or_consistency[:timeout]
    trace = options_or_consistency[:trace]
  end
  return consistency, timeout, trace
end