Sha256: bd408a4020bfc500fc6096eee0e2c374587e4f4f926756dab553287d86d9296c
Contents?: true
Size: 692 Bytes
Versions: 19
Compression:
Stored size: 692 Bytes
Contents
module Funkr class Matcher def initialize(match) @const, *@data = match @runner = nil @undefined = self.class.constructs.clone end def self.build_matchers(constructs) @constructs = constructs constructs.each do |c| name, *data = c define_method(name) do |&b| @undefined.delete(name) if @const == name then @runner = b end end end end def self.constructs; @constructs; end def run_match if @undefined.any? then raise "Incomplete match, missing : #{@undefined.join(" ")}" end @runner.call(*@data) end end end
Version data entries
19 entries across 19 versions & 1 rubygems