21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/igniter/extensions/contracts/lookup_pack.rb', line 21
def lookup_keyword
Igniter::Contracts::DslKeyword.new(:lookup) do |name, from:, builder:, key: nil, dig: nil, default: Igniter::Contracts::PathAccess::NO_DEFAULT|
source_name = from.to_sym
path = Igniter::Contracts::PathAccess.normalize_path(
keyword_name: :lookup,
key: key,
dig: dig
)
builder.add_operation(
kind: :compute,
name: name,
depends_on: [source_name],
callable: lambda do |**values|
source = values.fetch(source_name)
Igniter::Contracts::PathAccess.fetch_path(
source,
path,
source_name: source_name,
keyword_name: :lookup,
default: default
)
end
)
end
end
|