Skip to content

Instantly share code, notes, and snippets.

@jadeallenx
Created March 11, 2013 16:15
Show Gist options
  • Save jadeallenx/5135390 to your computer and use it in GitHub Desktop.
Save jadeallenx/5135390 to your computer and use it in GitHub Desktop.
MooX::Types::MooseLike::Base demo
use 5.016;
package Example {
use Moo;
use MooX::Types::MooseLike::Base qw(Int Str);
has 'foo' => ( is => 'ro', isa => Str, default => sub { 'bar' } );
has 'qux' => ( is => 'ro', isa => Int, default => sub { 123 } );
1;
}
my $example = Example->new(
qux => "foo"
);
@jadeallenx
Copy link
Author

Output:

$ perl d.pl
isa check for "qux" failed: foo is not an integer! at (eval 13) line 60.
    Example::new('Example', 'qux', 'foo') called at d.pl line 13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment