Skip to content

Instantly share code, notes, and snippets.

@benvanstaveren
Created June 5, 2011 20:43
Show Gist options
  • Save benvanstaveren/1009403 to your computer and use it in GitHub Desktop.
Save benvanstaveren/1009403 to your computer and use it in GitHub Desktop.
# 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