Sha256: bf88205a4589c33c892062904a9f44da5d68293dbb92d68ce80a088f293faef7

Contents?: true

Size: 389 Bytes

Versions: 40

Compression:

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

40 entries across 40 versions & 1 rubygems

Version Path
eco-helpers-3.0.1 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-3.0.0 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.7.25 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.7.24 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.7.23 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.7.22 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.7.21 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.7.20 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.7.19 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.7.18 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.7.17 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.7.16 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.7.15 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.7.14 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.7.13 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.7.12 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.7.4 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.7.2 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.7.1 lib/eco/api/common/people/default_parsers/boolean_parser.rb
eco-helpers-2.7.0 lib/eco/api/common/people/default_parsers/boolean_parser.rb