View Source Estructura.LazyMap (estructura v0.4.0)

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.)

Link to this section Summary

Functions

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.

Link to this section Types

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

Link to this section Functions

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

Examples

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