Sha256: 2a4a3d9db5e61fde0f7bf0f192e9662fb3016971443d8d68b8b39aada1dce6cb

Contents?: true

Size: 841 Bytes

Versions: 3

Compression:

Stored size: 841 Bytes

Contents

class Eco::API::Common::People::DefaultParsers::LoginProvidersParser < Eco::API::Common::Loaders::Parser
  attribute "login_provider_ids"
  parsing_phase     :final
  serializing_phase :final

  def parser(hash, _deps)
    hash["login_provider_ids"].map do |name|
      login_providers.to_id(name&.downcase&.strip).tap do |known|
        unless !name || known || unknown_pgs.include?(name)
          unknown_pgs.push(name)
          logger.warn("Unknown Login Provider: '#{name}'")
        end
      end
    end.compact
  end

  def serializer(hash, _deps)
    if (ids = hash["login_provider_ids"])
      login_providers.to_name(ids)
    else
      []
    end
  end

  private

  def unknown_pgs
    @unknown_pgs ||= []
  end

  def login_providers
    @login_providers ||= config.login_providers
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
eco-helpers-2.7.2 lib/eco/api/common/people/default_parsers/login_providers_parser.rb
eco-helpers-2.7.1 lib/eco/api/common/people/default_parsers/login_providers_parser.rb
eco-helpers-2.7.0 lib/eco/api/common/people/default_parsers/login_providers_parser.rb