def validates_numericality_of(*attr_names)
configuration = { :message => BigRecord::Errors.default_error_messages[:not_a_number], :on => :save,
:only_integer => false, :allow_nil => false }
configuration.update(attr_names.pop) if attr_names.last.is_a?(Hash)
if configuration[:only_integer]
validates_each(attr_names,configuration) do |record, attr_name,value|
record.errors.add(attr_name, configuration[:message]) unless record.send("#{attr_name}_before_type_cast").to_s =~ /\A[+-]?\d+\Z/
end
else
validates_each(attr_names,configuration) do |record, attr_name,value|
next if configuration[:allow_nil] and record.send("#{attr_name}_before_type_cast").nil?
begin
Kernel.Float(record.send("#{attr_name}_before_type_cast").to_s)
rescue ArgumentError, TypeError
record.errors.add(attr_name, configuration[:message])
end
end
end
end