Class: Sanitized::Float
- Inherits:
-
ActiveModel::Type::Float
- Object
- ActiveModel::Type::Float
- Sanitized::Float
- Includes:
- Base
- Defined in:
- lib/sanitized/float.rb
Overview
Description
ActiveModel::Type to cast and sanitize a model’s Float attribute according to the options specified on initialisation.
attribute :attr_name, Sanitized::Float.new(:abs, :ceil), default: 123.45
Can optionally include a custom block:
type_cast = Sanitized::Float.new(:abs, :ceil) do |value|
... custome code ...
end
attribute :attr_name, type_cast, default: 123.45
Class Method Summary collapse
-
.valid_options ⇒ Object
Returns a Hash of valid options with the other options they are exclusive with.
Methods included from Base
Class Method Details
.valid_options ⇒ Object
Returns a Hash of valid options with the other options they are exclusive with
36 37 38 39 40 41 42 43 44 |
# File 'lib/sanitized/float.rb', line 36 def self. { abs: [:magnitude], ceil: [:floor], floor: [:ceil], magnitude: [:abs], truncate: [], } end |