summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2011-07-08 23:11:34 -0500
committerJesse Luehrs <doy@tozt.net>2011-07-08 23:11:34 -0500
commit9174cec546b4dba5821ce29a408feb860f49c244 (patch)
tree10028a63e7cc2985461d0f9b4bb83c411db77020 /lib
parent6c7d5e2e4024df3b3d0f54bab14909ddfcd478c0 (diff)
downloadsmartmatch-9174cec546b4dba5821ce29a408feb860f49c244.tar.gz
smartmatch-9174cec546b4dba5821ce29a408feb860f49c244.zip
split rjbs engine out into its own dist
Diffstat (limited to 'lib')
-rw-r--r--lib/smartmatch/engine/rjbs.pm62
1 files changed, 0 insertions, 62 deletions
diff --git a/lib/smartmatch/engine/rjbs.pm b/lib/smartmatch/engine/rjbs.pm
deleted file mode 100644
index da40998..0000000
--- a/lib/smartmatch/engine/rjbs.pm
+++ /dev/null
@@ -1,62 +0,0 @@
-package smartmatch::engine::rjbs;
-use strict;
-use warnings;
-
-use overload ();
-use Scalar::Util qw(blessed reftype);
-
-sub type {
- my ($thing) = @_;
-
- if (!defined($thing)) {
- return 'undef';
- }
- elsif (!ref($thing)) {
- return 'unknown non-ref';
- }
- elsif (reftype($thing) eq 'REGEXP') {
- return 'Regex';
- }
- elsif (blessed($thing)) {
- if (overload::Method($thing, '~~')) {
- return 'Overloaded';
- }
- elsif (overload::Method($thing, 'qr')) {
- return 'Regex';
- }
- else {
- return 'unknown object';
- }
- }
- elsif (reftype($thing) eq 'CODE') {
- return 'Code';
- }
- else {
- return 'unknown';
- }
-}
-
-sub match {
- my ($a, $b) = @_;
-
- if (type($b) eq 'undef') {
- return !defined($a);
- }
- elsif (type($b) eq 'Overloaded') {
- my $overload = overload::Method($b, '~~');
- return $b->$overload($a, 1);
- }
- elsif (type($b) eq 'Regex') {
- return $a =~ $b;
- }
- elsif (type($b) eq 'Code') {
- return $b->($a);
- }
- else {
- $a //= 'undef';
- $b //= 'undef';
- die "invalid smart match: $a ~~ $b";
- }
-}
-
-1;