Class: Dhall::ExpressionResolver::ImportResolver

Inherits:
Dhall::ExpressionResolver show all
Defined in:
lib/dhall/resolve.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Dhall::ExpressionResolver

for, #initialize, register_for

Constructor Details

This class inherits a constructor from Dhall::ExpressionResolver

Class Method Details

.new(expr) ⇒ Object



434
435
436
437
438
439
440
# File 'lib/dhall/resolve.rb', line 434

def self.new(expr)
	if expr.import_type == Import::AsLocation
		ImportAsLocationResolver.new(expr)
	else
		super
	end
end

Instance Method Details

#resolve(resolver:, relative_to:) ⇒ Object



442
443
444
445
446
447
448
# File 'lib/dhall/resolve.rb', line 442

def resolve(resolver:, relative_to:)
	Promise.resolve(nil).then do
		resolver.cache_fetch(@expr.cache_key(relative_to)) do
			resolve_raw(resolver: resolver, relative_to: relative_to)
		end
	end
end

#resolve_raw(resolver:, relative_to:) ⇒ Object



450
451
452
453
454
455
456
457
458
459
460
# File 'lib/dhall/resolve.rb', line 450

def resolve_raw(resolver:, relative_to:)
	real_path = @expr.real_path(relative_to)
	real_path.resolve(resolver).then do |result|
		@expr.parse_resolve_check(
			result,
			deadline:    resolver.deadline,
			resolver:    resolver.child(real_path),
			relative_to: real_path
		)
	end
end