Sha256: 6535001ed2bf28ec66bad360ae5731b28d160dc200693ae7ed8e967ed88dd7ed

Contents?: true

Size: 391 Bytes

Versions: 53

Compression:

Stored size: 391 Bytes

Contents

class Eco::API::Common::People::DefaultParsers::BooleanParser < Eco::API::Common::Loaders::Parser
  attribute :boolean

  def parser(value, deps)
    value.is_a?(Array) ? value.map { |v| truthy(v) } : truthy(value)
  end

  def serializer(value, deps)
    value.to_s
  end

  private

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

end

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
eco-helpers-2.6.4 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.6.3 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.6.2 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.6.1 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.6.0 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.5.10 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.5.9 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.5.8 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.5.7 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.5.6 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.5.5 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.5.4 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.5.3 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.5.2 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.5.1 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.4.9 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.4.8 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.4.7 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.4.6 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.4.5 lib/eco/api/common/people/default_parsers/boolean_parser.rb