Class: RailsSimpleParams::Coercion::FloatParam

Inherits:
Base
  • Object
show all
Defined in:
lib/rails_simple_params/coercion/float_param.rb

Instance Attribute Summary

Attributes inherited from Base

#options, #param, #type

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from RailsSimpleParams::Coercion::Base

Instance Method Details

#coerceObject



6
7
8
9
10
# File 'lib/rails_simple_params/coercion/float_param.rb', line 6

def coerce
  return nil if param == '' # e.g. from an empty field in an HTML form

  Float(param)
end