ConfigurationSwitcher

public class ConfigurationSwitcher

ConfigurationSwitcher is a singleton that allows for environment/configuration switching when working with staging/production environments. Selections are persistent across sessions and can be updated on the fly.

  • Getter/Setter for the current ServerConfiguration identity. When setting this value it will write to UserDefaults using the defaultsKey value as the key.

    Complexity

    O(1)

    Declaration

    Swift

    public var configuration: String { get set }

    Return Value

    A string value representing the indetity of the currently selected ServerConfiguration

  • Getter for the current ServerConfiguration environment variables.

    Complexity

    O(1)

    Declaration

    Swift

    public var environmentVariables: [String : String] { get }

    Return Value

    A dictionary value representing the identity of the currently selected ServerConfiguration

  • Setter for a given ServerConfiguration object. Must use this setter as ConfigurationSwitcher.init() is marked internal for API purposes. Calling this function will remove all duplicate ServerConfiguration objects based on the identifier that is passed in.

    Complexity

    O(n) where n is the number of ServerConfiguration objects inside the configurations array that have the identifier

    Declaration

    Swift

    public func configureEnvironment(withIdentifier identifier: String, variables: [String : String] = [:])

    Parameters

    identifier

    The name of the environment that the caller is attempting to set the value of.

    variables

    The dictionary that the caller/client’s application has configured for this environment.