class Sanitized::Decimal
Description¶ ↑
ActiveModel::Type to cast and sanitize a model’s Decimal
attribute according to the options specified on initialisation.
attribute :attr_name, Sanitized::Decimal.new(:abs, :ceil), default: 123.45
Can optionally include a custom block:
type_cast = Sanitized::Decimal.new(:abs, :ceil) do |value| ... custome code ... end attribute :attr_name, type_cast, default: 123.45
Public Class Methods
valid_options()
click to toggle source
Returns a Hash of valid options with the other options they are exclusive with
# File lib/sanitized/decimal.rb, line 36 def self.valid_options { abs: [], ceil: [:floor], floor: [:ceil], truncate: [] } end