Sha256: 9add0232fdb9b4d2577fa7a837868403885024c6f33ba32388e67a9479356741
Contents?: true
Size: 559 Bytes
Versions: 1
Compression:
Stored size: 559 Bytes
Contents
module Configurable module ConfigTypes class BooleanType < ObjectType matches TrueClass, FalseClass # Casts the input to a boolean ie: # # true, 'true' => true # false, 'false => false # # All other inputs raise an ArgumentError. def cast(input) case input when true, false then input when 'true' then true when 'false' then false else raise ArgumentError, "invalid value for boolean: #{input.inspect}" end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
configurable-1.0.0 | lib/configurable/config_types/boolean_type.rb |