View Source Estructura.LazyMap (estructura v1.4.2)

The implementation of lazy map implementing lazy Access for its keys.

Estructura.LazyMap is backed by the “raw” object and a key-value pairs where values might be instances of Estructura.Lazy. If this is a case, they will be accessed through Lazy implementation.

Values might be also raw values, which makes LazyMap a drop-in replacement of standard Elixir maps, assuming they are accessed through Access only (e. g. map[:key] and not map.key.)

Summary

Functions

Eagerly instantiates the data

Returns all the keys of the underlying map

Creates new instance of LazyMap with a second parameter being a backed up object, which would be used for lazy retrieving data for values, when value is an instance of Estructura.Lazy.

Types

@type t() :: %Estructura.LazyMap{__lazy_data__: term(), data: map()}

Functions

Link to this function

fetch_all(lazy)

View Source (since 0.4.1)
@spec fetch_all(t()) :: t()

Eagerly instantiates the data

Link to this function

keys(lazy_map)

View Source (since 0.4.1)
@spec keys(t()) :: [Map.key()]

Returns all the keys of the underlying map

Link to this function

new(initial \\ %{}, lazy_data \\ nil)

View Source

Creates new instance of LazyMap with a second parameter being a backed up object, which would be used for lazy retrieving data for values, when value is an instance of Estructura.Lazy.

Examples

iex> lm = Estructura.LazyMap.new(
...>   [int: Estructura.Lazy.new(&Estructura.LazyInst.parse_int/1)], "42")
...> get_in lm, [:int]
42