2 package Class::MOP::Method::Overload;
9 use base 'Class::MOP::Method';
14 unshift @args, 'body' if @args % 2 == 1;
17 confess "operator is required"
18 unless exists $params{operator};
20 return $class->SUPER::wrap(
21 name => "($params{operator}",
28 return Class::MOP::Class->initialize($class)->new_object(@_)
29 if $class ne __PACKAGE__;
31 my $params = @_ == 1 ? $_[0] : {@_};
34 # inherited from Class::MOP::Method
35 'body' => $params->{body},
36 'associated_metaclass' => $params->{associated_metaclass},
37 'package_name' => $params->{package_name},
38 'name' => $params->{name},
39 'original_method' => $params->{original_method},
41 # defined in this class
42 'operator' => $params->{operator},
48 # ABSTRACT: Method Meta Object for methods which implement overloading
56 This is a L<Class::MOP::Method> subclass which represents methods that
57 implement overloading.
63 =item B<< Class::MOP::Method::Overload->wrap($metamethod, %options) >>
65 This is the constructor. The options accepted are identical to the ones
66 accepted by L<Class::MOP::Method>, except that it also required an C<operator>
67 parameter, which should be an operator as defined by the L<overload> pragma.
69 =item B<< $metamethod->operator >>
71 This returns the operator that was passed to new.