Skip to content

Instantly share code, notes, and snippets.

@realdecisions
Created December 29, 2015 19:04
Show Gist options
  • Save realdecisions/dba006acf5816230ddb0 to your computer and use it in GitHub Desktop.
Save realdecisions/dba006acf5816230ddb0 to your computer and use it in GitHub Desktop.
Mouse import.
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