Class: Dhall::ExpressionResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/dhall/resolve.rb

Defined Under Namespace

Classes: ArrayResolver, FallbackResolver, HashResolver, IdentityResolver, ImportResolver, RecordResolver

Constant Summary collapse

@@registry =
{}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expr) ⇒ ExpressionResolver



418
419
420
# File 'lib/dhall/resolve.rb', line 418

def initialize(expr)
  @expr = expr
end

Class Method Details

.for(expr) ⇒ Object



410
411
412
# File 'lib/dhall/resolve.rb', line 410

def self.for(expr)
  @@registry.find { |k, _| k === expr }.last.new(expr)
end

.register_for(kase) ⇒ Object



414
415
416
# File 'lib/dhall/resolve.rb', line 414

def self.register_for(kase)
  @@registry[kase] = self
end

Instance Method Details

#resolve(**kwargs) ⇒ Object



422
423
424
425
426
427
428
# File 'lib/dhall/resolve.rb', line 422

def resolve(**kwargs)
  Util.promise_all_hash(
    @expr.to_h.each_with_object({}) { |(attr, value), h|
      h[attr] = ExpressionResolver.for(value).resolve(**kwargs)
    }
  ).then { |h| @expr.with(h) }
end