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.16 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.0.15 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.0.14 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.0.13 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.0.12 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.0.11 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.0.10 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.0.9 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.0.8 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.0.7 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.0.6 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.0.5 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.0.4 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.0.3 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.0.2 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-1.5.15 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-1.5.14 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-1.5.13 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-1.5.12 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-1.5.11 lib/eco/api/common/people/default_parsers/boolean_parser.rb