Sha256: 796e59418283b7b47c832c5d5423a4b9f4e5059f7d6b72b42c7a389bfe1c0651

Contents?: true

Size: 352 Bytes

Versions: 4

Compression:

Stored size: 352 Bytes

Contents

module Decanter
  module Parser
    class BooleanParser < ValueParser

      allow TrueClass, FalseClass

      parser do |val, options|
        raise Decanter::ParseError.new 'Expects a single value' if val.is_a? Array
        next if (val.nil? || val === '')
        [1, '1'].include?(val) || !!/^true$/i.match?(val.to_s)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
decanter-4.0.4 lib/decanter/parser/boolean_parser.rb
decanter-4.0.3 lib/decanter/parser/boolean_parser.rb
decanter-4.0.2 lib/decanter/parser/boolean_parser.rb
decanter-4.0.1 lib/decanter/parser/boolean_parser.rb