Class: PatternMatching::MatchExec
- Inherits:
-
Object
- Object
- PatternMatching::MatchExec
- Defined in:
- lib/patternmatching/pattern.rb
Overview
Private class to run pattern matching
Defined Under Namespace
Classes: ExecuteAs, InstanceVariableAccessor
Class Method Summary collapse
Class Method Details
.exec_as(target, patterns, receiver) ⇒ Object
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
# File 'lib/patternmatching/pattern.rb', line 206 def self.exec_as(target, patterns, receiver) patterns.each do |tuple| pattern = tuple[0] action = tuple[1] condition = tuple[2] source = NodeBuilder.new.instance_eval(&pattern) args = {} begin Collector.walk(source, target, args) rescue NotMatched next end executer = ExecuteAs.new(args, receiver) next if condition != nil and not executer.instance_eval(&condition) return [executer, action] end nil end |