View Source Estructura.Lazy (estructura v0.4.2)
The field stub allowing lazy instantiation of Estructura
fields.
Link to this section Summary
Functions
Apply the lazy getter to the data passed as an argument
Create the new struct with the getter passed as an argument
Validates if the value is not stale yet according to expires_in
setting
Link to this section Types
@type key() :: Map.key()
@type t() :: %Estructura.Lazy{ expires_in: non_neg_integer() | :instantly | :never, timestamp: nil | DateTime.t(), payload: any(), value: cached(), getter: getter() }
@type value() :: Map.value()
Link to this section Functions
Apply the lazy getter to the data passed as an argument
examples
Examples
iex> lazy = Estructura.Lazy.new(&System.fetch_env/1)
...> Estructura.Lazy.apply(lazy, "LANG").value
System.fetch_env("LANG")
@spec new(getter(), non_neg_integer() | :instantly | :never) :: t()
Create the new struct with the getter passed as an argument
Validates if the value is not stale yet according to expires_in
setting