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.



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

def initialize(default_consistency)
  @default_consistency = default_consistency
end

Instance Method Details

#decode_options(options_or_consistency) ⇒ Object



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

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