Class: Dynamoid::TypeCasting::IntegerTypeCaster

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

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

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

Instance Method Details

#process(value) ⇒ Object



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

def process(value)
  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
end