use Scalar::Util directly
[gitmo/Mouse.git] / lib / MouseX / Types / TypeDecorator.pm
CommitLineData
6da1e936 1package MouseX::Types::TypeDecorator;
2
3use strict;
4use warnings;
5
6c169c50 6use Scalar::Util 'blessed';
6da1e936 7
8use overload(
9 '""' => sub { ${ $_[0] } },
10 '|' => sub {
11
12 ## It's kind of ugly that we need to know about Union Types, but this
13 ## is needed for syntax compatibility. Maybe someday we'll all just do
14 ## Or[Str,Str,Int]
15
16 my @tc = grep {blessed $_} @_;
17 use Data::Dumper;
18 my $ret;
19 if (ref($_[0])) {
20 $ret = ${ $_[0] };
21 } else {
22 $ret = $_[0];
23 }
24 $ret .= '|';
25 if (ref($_[1])) {
26 $ret .= ${ $_[1] };
27 } else {
28 $ret .= $_[1];
29 }
30 $ret;
31 },
32 fallback => 1,
33
34);
35
36sub new {
37 my $type = $_[1];
38 bless \$type, $_[0];
39}
40
411;