lib/finitio/system.rb in finitio-0.11.3 vs lib/finitio/system.rb in finitio-0.11.4

- old
+ new

@@ -48,28 +48,27 @@ end def fetch(name, with_imports = true, &bl) if with_imports @types.fetch(name) do - _fetch(name, @imports, &bl) + fetch_on_imports(name, &bl) end else @types.fetch(name, &bl) end end - def _fetch(name, imports, &bl) + def fetch_on_imports(name, imports = @imports, &bl) if imports.empty? raise KeyError, %Q{key not found: "#{name}"} unless bl bl.call(name) else imports.first.fetch(name, false) do - _fetch(name, imports[1..-1], &bl) + fetch_on_imports(name, imports[1..-1], &bl) end end end - private :_fetch def factory @factory ||= TypeFactory.new end @@ -87,25 +86,15 @@ def parse(source) require_relative "syntax" Syntax.compile(source, self.dup) end - def resolve_proxies(recurse = true) - rebuilt = {} - scope = FetchScope.new(self, rebuilt) - types.each_with_object(rebuilt) do |(name,type),memo| - rebuilt[name] = type.resolve_proxies(scope) - end - resolved = System.new(rebuilt, imports) - recurse ? resolved.resolve_proxies(false) : resolved - end - def inspect @types.each_pair.map{|k,v| "#{k} = #{v}" }.join("\n") end - def dup - System.new(@types.dup, @imports.dup) + def dup(types = @types.dup, imports = @imports.dup) + System.new(types, imports) end def check_and_warn(logger = nil) logger ||= begin require 'logger'