Sha256: 840b50e38b02dfcb74f49c865be47103d50726d0536e59a4b2020a28eae3b7d7

Contents?: true

Size: 799 Bytes

Versions: 37

Compression:

Stored size: 799 Bytes

Contents

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

            def process
              @parsers.define_attribute("send_invites") do |parser|
                parser.def_parser  do |hash|
                  value = hash["send_invites"]
                  value.is_a?(Array) ? value.map { |v| truthy(v) } : truthy(value)
                end.def_serializer do |person|
                  person.account && person.account.send_invites&.to_s
                end
              end
            end

            private

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

Version data entries

37 entries across 37 versions & 1 rubygems

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