class IknowParams::Serializer::Boolean
Public Class Methods
new()
click to toggle source
Calls superclass method
IknowParams::Serializer::new
# File lib/iknow_params/serializer.rb, line 138 def initialize super(nil) end
Public Instance Methods
load(str)
click to toggle source
# File lib/iknow_params/serializer.rb, line 142 def load(str) str = str.downcase if str.is_a?(::String) if ['false', 'no', 'off', false, '0', 0].include?(str) false elsif ['true', 'yes', 'on', true, '1', 1].include?(str) true else raise LoadError.new("Invalid boolean: #{str.inspect}") end end
matches_type?(val)
click to toggle source
# File lib/iknow_params/serializer.rb, line 154 def matches_type?(val) [true, false].include?(val) end