Perl 6 is supposed to have native support for something like that. Constructor takes multiple patterns. The object matches if they all match.
Usage:
case foo when all(:foo, any({:color => 'blue'}, {:color => 'red'}), /Hello/) print foo end
Methods
Public Class methods
[ show source ]
# File magic_xml.rb, line 1369 def initialize(*patterns) @patterns = patterns end
Public Instance methods
[ show source ]
# File magic_xml.rb, line 1372 def ===(obj) @patterns.any?{|p| p === obj} end