Created
June 5, 2011 20:43
-
-
Save benvanstaveren/1009403 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
# If you look at my Monger repository, imagine the following snippet being stuck in | |
# Monger.pm | |
BEGIN { | |
Moose::Meta::Class->meta->make_mutable; | |
Moose::Meta::Class->meta->add_before_method_modifier('make_immutable', sub { | |
my $self = shift; | |
my $name = $self->name; | |
# apply the dbref role if, and only if, we're a monger::document | |
if($name->isa('Monger::Document') && $name ne 'Monger::Document') { | |
ensure_all_roles($name, 'Monger::Role::::DBref'); | |
} | |
}); | |
Moose::Meta::Class->meta->make_immutable; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment