Created
June 12, 2017 03:29
-
-
Save moznion/afe57cfcbdf89727406fcc9a7b286200 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use utf8; | |
use feature qw/state say/; | |
use Data::Validator; | |
package Foo { | |
sub build { | |
state $rule = Data::Validator->new( | |
item => {isa => 'Bar|Buz'}, | |
)->with('Method'); | |
my ($class, $argument) = $rule->validate(@_); | |
say 'OK'; | |
} | |
} | |
package Bar { | |
sub new { | |
bless {}, $_[0]; | |
} | |
} | |
package Buz { | |
sub new { | |
bless {}, $_[0]; | |
} | |
} | |
Foo->build({item => Bar->new}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment