Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add additional docs

  • Loading branch information...
commit eae6c5d29747f9bb03e7f10ddbf1d78cbeb15072 1 parent b898cee
@bobtfish bobtfish authored
View
2  dist.ini
@@ -8,6 +8,8 @@ copyright_holder = Florian Ragwitz
[Prereq]
Moose = 0.88
aliased = 0
+namespace::clean = 0
+namespace::autoclean = 0
[@Filter]
bundle = @Classic
View
28 lib/MooseX/Role/WithOverloading.pm
@@ -30,14 +30,36 @@ sub init_meta {
=head1 SYNOPSIS
package MyRole;
- use Moose::Role;
+ use MooseX::Role::WithOverloading;
use namespace::autoclean;
- with 'MooseX::Role::WithOverloading';
+ use overload
+ q{""} => 'as_string',
+ fallback => 1;
+
+ has message => (
+ is => 'rw',
+ isa => 'Str',
+ );
+
+ sub as_string { shift->message }
+
+ package MyClass;
+ use Moose;
+ use namespace::autoclean;
+
+ with 'MyRole';
+
+ package main;
+
+ my $i = MyClass->new( message => 'foobar' );
+ print $i; # Prints 'foobar'
=head1 DESCRIPTION
-FIXME
+MooseX::Role::WithOverloading allows you to write a L<Moose::Role>
+which uses operator overloading to overload any operation supported by the
+L<overload> pragma.
=begin Pod::Coverage
View
5 lib/MooseX/Role/WithOverloading/Meta/Role.pm
@@ -10,9 +10,4 @@ has '+composition_class_roles' => (
1;
-=head1 DESCRIPTION
-
-FIXME
-
-=cut
View
24 lib/MooseX/Role/WithOverloading/Meta/Role/Application.pm
@@ -1,10 +1,18 @@
package MooseX::Role::WithOverloading::Meta::Role::Application;
-# ABSTRACT: Roles which support overloading
+# ABSTRACT: Role application role for Roles which support overloading
use Moose::Role;
use overload ();
use MooseX::Types::Moose qw/ArrayRef Str/;
use namespace::autoclean;
+requires 'apply_methods';
+
+=method overload_ops
+
+Returns an arrayref of the names of overloaded operations
+
+=cut
+
has overload_ops => (
is => 'ro',
isa => ArrayRef[Str],
@@ -15,11 +23,25 @@ sub _build_overload_ops {
return [map { split /\s+/ } values %overload::ops];
}
+=method apply_methods ($role, $other)
+
+Wrapped with an after modifier which calls the C<< ->apply_overloading >>
+method.
+
+=cut
+
after apply_methods => sub {
my ($self, $role, $other) = @_;
$self->apply_overloading($role, $other);
};
+=method apply_overloading ($role, $other)
+
+Does the heavy lifting of applying overload operations to
+a class or role which the role is applied to.
+
+=cut
+
sub apply_overloading {
my ($self, $role, $other) = @_;
return unless overload::Overloaded($role->name);
View
2  lib/MooseX/Role/WithOverloading/Meta/Role/Application/Composite/ToClass.pm
@@ -1,5 +1,5 @@
package MooseX::Role::WithOverloading::Meta::Role::Application::Composite::ToClass;
-
+# ABSTRACT: Roles which support overloading
use Moose::Role;
use namespace::autoclean;
View
2  lib/MooseX/Role/WithOverloading/Meta/Role/Application/Composite/ToInstance.pm
@@ -1,5 +1,5 @@
package MooseX::Role::WithOverloading::Meta::Role::Application::Composite::ToInstance;
-
+# ABSTRACT: Roles which support overloading
use Moose::Role;
use namespace::autoclean;
View
2  lib/MooseX/Role/WithOverloading/Meta/Role/Application/Composite/ToRole.pm
@@ -1,5 +1,5 @@
package MooseX::Role::WithOverloading::Meta::Role::Application::Composite::ToRole;
-
+# ABSTRACT: Roles which support overloading
use Moose::Role;
use namespace::autoclean;
View
10 lib/MooseX/Role/WithOverloading/Meta/Role/Composite.pm
@@ -1,12 +1,18 @@
package MooseX::Role::WithOverloading::Meta::Role::Composite;
-# ABSTRACT: Roles which support overloading
+# ABSTRACT: Role for composite roles which support overloading
use Moose::Role;
use Moose::Util::MetaRole;
use aliased 'MooseX::Role::WithOverloading::Meta::Role::Application::Composite::ToClass';
use aliased 'MooseX::Role::WithOverloading::Meta::Role::Application::Composite::ToRole';
use aliased 'MooseX::Role::WithOverloading::Meta::Role::Application::Composite::ToInstance';
-use namespace::clean -except => 'meta';
+use namespace::autoclean;
+
+=method apply_params
+
+Wrapped method to apply various metaclass roles to aid with role composition.
+
+=cut
around apply_params => sub {
my ($next, $self, @args) = @_;
Please sign in to comment.
Something went wrong with that request. Please try again.