Sha256: 71861f77344b33169337cda44bd7093613ef77c130a468d340fc0e14df2adb64

Contents?: true

Size: 392 Bytes

Versions: 69

Compression:

Stored size: 392 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

69 entries across 69 versions & 1 rubygems

Version Path
eco-helpers-2.0.57 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.0.56 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.0.55 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.0.54 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.0.53 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.0.52 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.0.51 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.0.50 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.0.49 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.0.48 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.0.47 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.0.46 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.0.45 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.0.44 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.0.43 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.0.42 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.0.41 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.0.40 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.0.39 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.0.38 lib/eco/api/common/people/default_parsers/boolean_parser.rb