From: Shawn M Moore Date: Wed, 16 Jul 2008 06:29:17 +0000 (+0000) Subject: Metaclass->add_method X-Git-Tag: 0.19~242 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d16fe7d79e7f254ed479b58681d716e78b3e8caf;p=gitmo%2FMouse.git Metaclass->add_method --- diff --git a/lib/Mouse/Meta/Class.pm b/lib/Mouse/Meta/Class.pm index bf3276a..2107011 100644 --- a/lib/Mouse/Meta/Class.pm +++ b/lib/Mouse/Meta/Class.pm @@ -54,6 +54,17 @@ sub superclasses { @{ $self->{superclasses} }; } +sub add_method { + my $self = shift; + my $name = shift; + my $code = shift; + + my $pkg = $self->name; + + no strict 'refs'; + *{ $pkg . '::' . $name } = $code; +} + sub add_attribute { my $self = shift; my $attr = shift;