ExMCP.Internal.MapBuilder (ex_mcp v1.0.0-rc.0)

View Source

Small pipe-friendly helpers for building protocol maps.

These helpers keep optional-field decisions explicit at call sites while avoiding repeated private maybe_put functions across MCP modules.

Summary

Functions

Puts value into map when the value is not nil.

Puts value into map when the value is truthy.

Puts value into map unless it equals skip_value.

Functions

put_if_present(map, key, value)

@spec put_if_present(map(), any(), any()) :: map()

Puts value into map when the value is not nil.

put_if_truthy(map, key, value)

@spec put_if_truthy(map(), any(), any()) :: map()

Puts value into map when the value is truthy.

put_unless(map, key, value, skip_value)

@spec put_unless(map(), any(), any(), any()) :: map()

Puts value into map unless it equals skip_value.