class HashCast::Casters::BooleanCaster
Constants
- FALSE_VALUES
- REAL_BOOLEANS
- TRUE_VALUES
Public Class Methods
cast(value, attr_name, options = {})
click to toggle source
# File lib/hashcast/casters/boolean_caster.rb, line 6 def self.cast(value, attr_name, options = {}) return value if REAL_BOOLEANS.include?(value.class) return true if TRUE_VALUES.include?(value) return false if FALSE_VALUES.include?(value) raise HashCast::Errors::CastingError, "should be a boolean" end