Sha256: 6098b906b0068b449cdfa99d50a050d4f63adda29eb63daa11268ecce1aeb90f

Contents?: true

Size: 705 Bytes

Versions: 23

Compression:

Stored size: 705 Bytes

Contents

module Eco
  module API
    module Common
      module People
        class DefaultParsers
          class BooleanParser < People::BaseParser

            def process
              @parsers.define_attribute(:boolean) do |parser|
                parser.def_parser  do |value|
                  value.is_a?(Array) ? value.map { |v| truthy(v) } : truthy(value)
                end.def_serializer do |value|
                  value.to_s
                end
              end
            end

            private

            def truthy (value)
              %w[true y yes x].include?(value.to_s.strip.downcase)
            end
          end
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
eco-helpers-1.5.1 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-1.5.0 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-1.4.2 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-1.3.19 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-1.4.1 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-1.4.0 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-1.3.18 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-1.3.17 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-1.3.16 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-1.3.15 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-1.3.14 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-1.3.13 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-1.3.12 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-1.3.11 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-1.3.10 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-1.3.9 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-1.3.8 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-1.3.7 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-1.3.6 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-1.3.5 lib/eco/api/common/people/default_parsers/boolean_parser.rb