Method: Dynamoid::TypeCasting::IntegerTypeCaster#process

Defined in:
lib/dynamoid/type_casting.rb

#process(value) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/dynamoid/type_casting.rb', line 74

def process(value)
  # rubocop:disable Lint/DuplicateBranch
  if value == true
    1
  elsif value == false
    0
  elsif value.is_a?(String) && value.blank?
    nil
  elsif value.is_a?(Float) && !value.finite?
    nil
  elsif !value.respond_to?(:to_i)
    nil
  else
    value.to_i
  end
  # rubocop:enable Lint/DuplicateBranch
end