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



269
270
271
272
273
274
275
276
277
278
279
280
281
282
# File 'lib/dynamoid/undumping.rb', line 269

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