Sha256: 35c694f15a1508a9afd9fe0a9267f22a9696280d6e2cfb77d81bb5f93a87fc7f

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

Contents

require_relative "includes"
require_relative "abstract_factory"

class AwsAssumeRole::Credentials::Factories::Repository
    include AwsAssumeRole::Credentials::Factories

    SubFactoryRepositoryType = Types::Hash.schema(Types::Coercible::Int => Types::Strict::Array)

    FactoryRepositoryType = Types::Hash.schema(
        credential_provider: SubFactoryRepositoryType,
        second_factor_provider: SubFactoryRepositoryType,
        instance_role_provider: SubFactoryRepositoryType,
    )

    def self.factories
        repository.keys.map { |t| [t, flatten_factory_type_list(t)] }.to_h
    end

    def self.repository
        @repository ||= FactoryRepositoryType[
            credential_provider: {},
            second_factor_provider: {},
            instance_role_provider: {},
        ]
    end

    def self.register_factory(klass, type, priority)
        repository[type][priority] ||= []
        repository[type][priority] << klass
    end

    def self.flatten_factory_type_list(type)
        repository[type].keys.sort.map { |x| @repository[type][x] }.flatten
    end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
aws_assume_role-0.2.2 lib/aws_assume_role/credentials/factories/repository.rb
aws_assume_role-0.2.0 lib/aws_assume_role/credentials/factories/repository.rb
aws_assume_role-0.1.2 lib/aws_assume_role/credentials/factories/repository.rb