get_list => 'get_required_method_list',
existence => 'requires_method',
}
- },
+ },
{
name => 'attribute_map',
attr_reader => 'get_attribute_map',
$self->add_package_symbol("&${method_name}" => $body);
}
-#sub reset_package_cache_flag { () }
-#sub update_package_cache_flag { () }
-
## ------------------------------------------------------------------
## role construction
## ------------------------------------------------------------------
if ($other->isa('Moose::Meta::Role')) {
require Moose::Meta::Role::Application::ToRole;
- return Moose::Meta::Role::Application::ToRole->new->apply($self, $other, @args);
+ return Moose::Meta::Role::Application::ToRole->new(@args)->apply($self, $other);
}
elsif ($other->isa('Moose::Meta::Class')) {
require Moose::Meta::Role::Application::ToClass;
- return Moose::Meta::Role::Application::ToClass->new->apply($self, $other, @args);
+ return Moose::Meta::Role::Application::ToClass->new(@args)->apply($self, $other);
}
else {
require Moose::Meta::Role::Application::ToInstance;
- return Moose::Meta::Role::Application::ToInstance->new->apply($self, $other, @args);
+ return Moose::Meta::Role::Application::ToInstance->new(@args)->apply($self, $other);
}
}
our $VERSION = '0.01';
our $AUTHORITY = 'cpan:STEVAN';
-# no need to get fancy here ...
-sub new { bless {} => (shift) }
+sub new { (shift)->meta->new_object(@_) }
sub apply {
my $self = shift;
$self->check_role_exclusions(@_);
$self->check_required_methods(@_);
+ $self->check_required_attributes(@_);
$self->apply_attributes(@_);
$self->apply_methods(@_);
sub check_role_exclusions { die "Abstract Method" }
sub check_required_methods { die "Abstract Method" }
+sub check_required_attributes { die "Abstract Method" }
+
sub apply_attributes { die "Abstract Method" }
sub apply_methods { die "Abstract Method" }
sub apply_override_method_modifiers { die "Abstract Method" }
=item B<apply>
+=item B<check_role_exclusions>
+
=item B<check_required_methods>
-=item B<check_role_exclusions>
+=item B<check_required_attributes>
=item B<apply_attributes>
$c->add_required_methods(keys %all_required_methods);
}
+sub check_required_attributes {
+
+}
+
sub apply_attributes {
my ($self, $c) = @_;
=item B<apply>
+=item B<check_role_exclusions>
+
=item B<check_required_methods>
-=item B<check_role_exclusions>
+=item B<check_required_attributes>
=item B<apply_attributes>
}
}
+sub check_required_attributes {
+
+}
+
sub apply_attributes {
my ($self, $role, $class) = @_;
foreach my $attribute_name ($role->get_attribute_list) {
=item B<apply>
+=item B<check_role_exclusions>
+
=item B<check_required_methods>
-=item B<check_role_exclusions>
+=item B<check_required_attributes>
=item B<apply_attributes>
}
}
+sub check_required_attributes {
+
+}
+
sub apply_attributes {
my ($self, $role1, $role2) = @_;
foreach my $attribute_name ($role1->get_attribute_list) {
=item B<apply>
+=item B<check_role_exclusions>
+
=item B<check_required_methods>
-=item B<check_role_exclusions>
+=item B<check_required_attributes>
=item B<apply_attributes>
=item Excluded Roles
+A role can have a list of excluded roles, these are basically
+roles that they shouldn't be composed with. This is not just
+direct composition either, but also "inherited" composition.
+
+This feature was taken from the Fortress language and is really
+of most use when building a large set of role "building blocks"
+some of which should never be used together.
+
=item Attributes
+A roles attributes are similar to those of a class, except that
+they are not actually applied. This means that methods that are
+generated by an attributes accessor will not be generated in the
+role, but only created once the role is applied to a class.
+
=item Methods
+These are the methods defined within the role. Simple as that.
+
=item Required Methods
+A role can require a consuming class (or role) to provide a
+given method. Failure to do so for classes is a fatal error,
+while for roles it simply passes on the method requirement to
+the consuming role.
+
+=item Required Attributes
+
+Just as a role can require methods, it can also require attributes.
+The requirement fufilling attribute must implement at least as much
+as is required. That means, for instance, that if the role requires
+that the attribute be readonly, then it must at least have a reader
+and can also have a writer. It means that if the role requires that
+the attribute be an ArrayRef, then it must either be an ArrayRef or
+a subtype of an ArrayRef.
+
=item Overriden Methods
The C<override> and C<super> keywords are allowed in roles, but
=item Method Modifiers
+These are the C<before>, C<around> and C<after> modifiers provided
+in Moose classes. The difference here is that the modifiers are not
+actually applied until the role is composed into a class (this is
+just like attributes and the C<override> keyword).
+
=back
-=head2 Role to Role Composition Rules
+=head2 Role Composition
+
+=head3 Composing into a Role
+
+=over 4
+
+=item Excluded Roles
+
+=item Required Methods
+
+=item Required Attributes
+
+=item Attributes
+
+=item Methods
+
+=item Overriden methods
+
+=item Method Modifiers (before, around, after)
+
+=back
-When a role is added to another role (using the C<with>
-keyword) the two roles are composed symmetrically. The
-product of the composition is a third composite role.
+=head3 Composing into a Class
=over 4
+=item Excluded Roles
+
+=item Required Methods
+
+=item Required Attributes
+
+=item Attributes
+
+=item Methods
+
+=item Overriden methods
+
+=item Method Modifiers (before, around, after)
+
+=back
+
+=head3 Composing into a Instance
+
+=head2 Role Summation
+
+When multiple roles are added to another role (using the
+C<with @roles> keyword) the roles are composed symmetrically.
+The product of the composition is a composite role
+(L<Moose::Meta::Role::Composite>).
+
+=over 4
+
+=item Excluded Roles
+
+=item Required Methods
+
+=item Required Attributes
+
=item Attributes
Attributes with the same name will conflict and are considered