Class: Dynamoid::Undumping::BooleanUndumper

Inherits:
Base
  • Object
show all
Defined in:
lib/dynamoid/undumping.rb

Constant Summary collapse

STRING_VALUES =
%w[t f].freeze

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Dynamoid::Undumping::Base

Instance Method Details

#process(value) ⇒ Object


251
252
253
254
255
256
257
258
259
260
261
262
263
264
# File 'lib/dynamoid/undumping.rb', line 251

def process(value)
  store_as_boolean = if @options[:store_as_native_boolean].nil?
                       Dynamoid.config.store_boolean_as_native
                     else
                       @options[:store_as_native_boolean]
                     end
  if store_as_boolean
    !!value
  elsif STRING_VALUES.include?(value)
    value == 't'
  else
    raise ArgumentError, 'Boolean column neither true nor false'
  end
end