rubyx/lib/util/compiler_list.rb
Torsten Rüger 2eb9364283 make mom:method_compiler a list
Compilers forms alist by Util::CompilerList
Change Collection to use the list instead of array
2019-09-28 12:41:38 +03:00

37 lines
787 B
Ruby

module Util
module CompilerList
attr_reader :next_compiler
def add_method_compiler(comp)
raise "not compiler #{comp.class}" unless comp.respond_to?(:find_compiler)
if(@next_compiler)
@next_compiler.add_method_compiler(comp)
else
@next_compiler = comp
end
end
def each_compiler &block
block.yield(self)
@next_compiler.each_compiler(&block) if @next_compiler
end
def find_compiler &block
return self if block.yield(self)
@next_compiler.find_compiler(&block) if @next_compiler
end
def last_compiler
return self unless @next_compiler
@next_compiler.last_compiler
end
def num_compilers
1 + (@next_compiler ? @next_compiler.num_compilers : 0)
end
end
end