Class: Dhall::ExpressionResolver

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

Defined Under Namespace

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

Constant Summary collapse

@@registry =
{}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expr) ⇒ ExpressionResolver

Returns a new instance of ExpressionResolver.



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

def initialize(expr)
	@expr = expr
end

Class Method Details

.for(expr) ⇒ Object



402
403
404
# File 'lib/dhall/resolve.rb', line 402

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

.register_for(kase) ⇒ Object



406
407
408
# File 'lib/dhall/resolve.rb', line 406

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

Instance Method Details

#resolve(**kwargs) ⇒ Object



414
415
416
417
418
419
420
# File 'lib/dhall/resolve.rb', line 414

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