lib/active_data/model/extensions/integer.rb in active_data-0.1.0 vs lib/active_data/model/extensions/integer.rb in active_data-0.2.0
- old
+ new
@@ -4,10 +4,10 @@
module Integer
extend ActiveSupport::Concern
module ClassMethods
def active_data_type_cast value
- value.try(:to_i) if value.to_s =~ /\A\d+(?:\.\d*)?\Z/
+ Float(value).to_i rescue nil if value
end
end
end
end
end