Module: Deterministic::PatternMatching
- Defined in:
- lib/deterministic/match.rb
Defined Under Namespace
Modules: Match Classes: NoMatchError
Instance Method Summary collapse
Instance Method Details
#match(context = nil, &block) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/deterministic/match.rb', line 4 def match(context=nil, &block) context ||= block.binding.eval('self') # the instance containing the match block match = binding.eval('self.class::Match.new(self, context)') # the class defining the Match match.instance_eval &block match.call end |