Created
December 29, 2015 19:04
-
-
Save realdecisions/dba006acf5816230ddb0 to your computer and use it in GitHub Desktop.
Mouse import.
This file contains hidden or 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
package ImportMe; | |
use Mouse; | |
my @imports; | |
sub import{ | |
my $class = shift; | |
my %args = @_; | |
my $cb = sub { | |
my $self = shift; | |
@{$self}{keys %args} = values %args; | |
}; | |
push @imports, $cb; | |
if($class->meta->name->can('BUILD')){ | |
# after builde | |
}else{ | |
*BUILD = sub{ | |
(shift @imports)->(@_); | |
}; | |
} | |
}; | |
has 'test' => (is => 'rw'); | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment