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.



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

def initialize(expr)
	@expr = expr
end

Class Method Details

.for(expr) ⇒ Object



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

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

.register_for(kase) ⇒ Object



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

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

Instance Method Details

#resolve(**kwargs) ⇒ Object



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

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