Sha256: a200fbdd93465ef012155b3c3921a683b2ead049c1ff84fae161ae13d3341235

Contents?: true

Size: 478 Bytes

Versions: 9

Compression:

Stored size: 478 Bytes

Contents

module Goliath
  module Rack
    module Types
      class Boolean < Base
        TRUE_STRINGS = ['true', 't', '1']
        FALSE_STRINGS = ['false', 'f', '0']
        ERROR_MESSAGE = "%s is not a boolean value"

        def _coerce(val)
          downcased_val = val.downcase
          return true if TRUE_STRINGS.include?(downcased_val)
          return false if FALSE_STRINGS.include?(downcased_val)
          raise ERROR_MESSAGE % val
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
goliath-1.0.7 lib/goliath/rack/types/boolean.rb
goliath-1.0.6 lib/goliath/rack/types/boolean.rb
goliath-1.0.5 lib/goliath/rack/types/boolean.rb
goliath-1.0.4 lib/goliath/rack/types/boolean.rb
goliath-1.0.3 lib/goliath/rack/types/boolean.rb
goliath-1.0.2 lib/goliath/rack/types/boolean.rb
goliath-1.0.1 lib/goliath/rack/types/boolean.rb
goliath-1.0.0 lib/goliath/rack/types/boolean.rb
goliath-1.0.0.beta.1 lib/goliath/rack/types/boolean.rb