View Source Estructura.LazyMap (estructura v1.6.1)

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

t()

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

Functions

fetch_all(lazy)

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

Eagerly instantiates the data

keys(lazy_map)

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

Returns all the keys of the underlying map

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

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