Module: Jade::ModuleLoader::ModuleName

Extended by:
ModuleName
Included in:
ModuleName
Defined in:
lib/jade/module_loader/module_name.rb

Overview

A module is keyed by the name its file implies — imports resolve Shop.Cart to shop/cart.jd and back. The wrapper takes the declared name while every type reference inside takes the file's, so a mismatch emits Ruby referring to a constant that was never defined.

Instance Method Summary collapse

Instance Method Details

#check(ast, source) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/jade/module_loader/module_name.rb', line 10

def check(ast, source)
  return Ok[ast] unless ast.is_a?(AST::Module)

  source.to_module_name.then do |expected|
    ast.name == expected ? Ok[ast] : Err[mismatch(ast, source, expected)]
  end
end