Class: Sanitized::Integer

Inherits:
ActiveModel::Type::Integer
  • Object
show all
Includes:
Base
Defined in:
lib/sanitized/integer.rb

Overview

Description

ActiveModel::Type to cast and sanitize a model’s Integer attribute according to the options specified on initialisation.

attribute :attr_name, Sanitized::Integer.new(:abs), default: 123

Can optionally include a custom block:

type_cast = Sanitized::Integer.new(:abs) do |value|
    ... custome code ...
end
attribute :attr_name, type_cast, default: 123

Class Method Summary collapse

Methods included from Base

#cast, #options

Class Method Details

.valid_optionsObject

Returns a Hash of valid options with the other options they are exclusive with



36
37
38
39
40
# File 'lib/sanitized/integer.rb', line 36

def self.valid_options
  {
    abs: []
  }
end