Sha256: 7bae9ec55d582d5c92b06ebdb0e34995e75139674c132d353a4e304dee661e68

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

module KeycloakRack
  # dry-rb types for this gem.
  #
  # @see https://dry-rb.org/gems/dry-types
  # @api private
  # @!visibility private
  module Types
    include Dry.Types

    # A type to make indifferent hashes
    #
    # @api private
    IndifferentHash = Types.Constructor(::ActiveSupport::HashWithIndifferentAccess) do |value|
      Types::Coercible::Hash[value].with_indifferent_access
    end

    # A type to validate skip paths
    #
    # @api private
    SkipPaths = Types::Hash.map(
      Types::Coercible::String,
      Types::Array.of(Types::String | Types.Instance(Regexp))
    )

    # A type to make arrays of strings
    StringList = Types::Array.of(Types::String).default { [] }

    # A type to parse timestamps
    # @api private
    Timestamp = Types.Constructor(::Time) do |value|
      # :nocov:
      case value
      when Integer then ::Time.at(value)
      when ::Time then value
      when Types.Interface(:to_time) then value.to_time
      end
      # :nocov:
    end.optional
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
keycloak_rack-1.1.1 lib/keycloak_rack/types.rb
keycloak_rack-1.1.0 lib/keycloak_rack/types.rb
keycloak_rack-1.0.0 lib/keycloak_rack/types.rb