Module: Sanitized::Base

Included in:
BigInteger, DateTime, Decimal, Float, Integer, String
Defined in:
lib/sanitized/base.rb

Overview

Base methods for all Sanitized classes

Instance Method Summary collapse

Instance Method Details

#cast(value) ⇒ Object

sanitize the value according to the options provided on initialization.



13
14
15
16
17
18
19
20
# File 'lib/sanitized/base.rb', line 13

def cast(value) # :nodoc:
  val = super
  val = sanitize(val)
  val = @block.call(val) if @block.present?
  return val
rescue
  nil
end

#optionsObject

public reader for set options



25
26
27
# File 'lib/sanitized/base.rb', line 25

def options
  @options ||= []
end