Sha256: ddae0233abb6f222c1de50b99564f119a00f953902229e1ae7fa88df07a9eb25
Contents?: true
Size: 809 Bytes
Versions: 5
Compression:
Stored size: 809 Bytes
Contents
module ATP module Processors # Removes any conditions nodes that are nested within other condition # nodes that specify the same condition class RedundantConditionRemover < Processor def run(node) @conditions = [] process(node) end def on_condition_node(node) sig = [node.type, node.to_a[0]] if @conditions.include?(sig) flag, *nodes = *node node.updated(:inline, process_all(nodes)) else @conditions << sig node = node.updated(nil, process_all(node.children)) @conditions.pop node end end ATP::Flow::CONDITION_NODE_TYPES.each do |type| alias_method "on_#{type}", :on_condition_node unless method_defined?("on_#{type}") end end end end
Version data entries
5 entries across 5 versions & 1 rubygems