View Source Waffle.Storage.Google.Util (Waffle backend for Google Cloud Storage v0.0.2)

A collection of utility functions.

Link to this section Summary

Functions

Attempts to return a value from a given options list, using the application configs as a back-up. The application (used in Application.get_env/3) is assumed to be :waffle.

If the given string does not already start with a forward slash, this function will prepend one and return the result.

Accepts four forms of variables

Link to this section Functions

Link to this function

option(opts, key, default \\ nil)

View Source
@spec option(Keyword.t(), any(), any()) :: any()

Attempts to return a value from a given options list, using the application configs as a back-up. The application (used in Application.get_env/3) is assumed to be :waffle.

This assumes that the application environment is set using waffle as the application name.

If the value is not found in any of those location, an optional default value can be returned.

@spec prepend_slash(String.t()) :: String.t()

If the given string does not already start with a forward slash, this function will prepend one and return the result.

examples

Examples

> prepend_slash("some/path")
"/some/path"

> prepend_slash("/im/good")
"/im/good"
@spec var(any()) :: any()

Accepts four forms of variables:

  1. The tuple {:system, key}, which uses System.get_env/1.
  2. The tuple {:app, key}, which uses Application.get_env/2.
  3. The tuple {:app, app, key}, which usees Application.get_env/2.
  4. Anything else which is returned as-is.

In the second form ({:app, key}), the application is assumed to be :waffle although this can be overriden using the third form ({:app, app, key}).