fix up the inlining test
[gitmo/Moose.git] / lib / Moose / Meta / TypeConstraint / Union.pm
index 5a2a6f1..ae0ea12 100644 (file)
@@ -7,6 +7,7 @@ use metaclass;
 
 use Moose::Meta::TypeCoercion::Union;
 
+use List::MoreUtils qw(all);
 use List::Util qw(first);
 
 use base 'Moose::Meta::TypeConstraint';
@@ -70,6 +71,27 @@ sub _actually_compile_type_constraint {
     };
 }
 
+sub can_be_inlined {
+    my $self = shift;
+
+    return all { $_->can_be_inlined } @{ $self->type_constraints };
+}
+
+sub _inline_check {
+    my $self = shift;
+    my $val  = shift;
+
+    return
+        join ' || ', map { '(' . $_->_inline_check($val) . ')' }
+        @{ $self->type_constraints };
+};
+
+sub inline_environment {
+    my $self = shift;
+
+    return { map { %{ $_->inline_environment } }
+            @{ $self->type_constraints } };
+}
 
 sub equals {
     my ( $self, $type_or_name ) = @_;