use Scalar::Util 'blessed';
use Class::MOP 0.60;
-our $VERSION = '0.96';
+our $VERSION = '1.09';
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
search_class_by_role
ensure_all_roles
apply_all_roles
+ with_traits
get_all_init_args
get_all_attribute_values
resolve_metatrait_alias
$meta = $role->[0];
}
else {
- Class::MOP::load_class( $role->[0] );
+ Class::MOP::load_class( $role->[0] , $role->[1] );
$meta = Class::MOP::class_of( $role->[0] );
}
}
}
+sub with_traits {
+ my ($class, @roles) = @_;
+ return $class unless @roles;
+ return Moose::Meta::Class->create_anon_class(
+ superclasses => [$class],
+ roles => \@roles,
+ cache => 1,
+ )->name;
+}
+
# instance deconstruction ...
sub get_all_attribute_values {
This function is similar to L</apply_all_roles>, but only applies roles that
C<$applicant> does not already consume.
+=item B<with_traits($class_name, @role_names)>
+
+This function creates a new class from C<$class_name> with each of
+C<@role_names> applied. It returns the name of the new class.
+
=item B<get_all_attribute_values($meta, $instance)>
Returns a hash reference containing all of the C<$instance>'s
The name resolution mechanism is covered in
L<Moose/Metaclass and Trait Name Resolution>.
-=item B<english_list(@items)>
-
-Given a list of scalars, turns them into a proper list in English
-("one and two", "one, two, three, and four"). This is used to help us
-make nicer error messages.
-
=item B<meta_class_alias($to[, $from])>
=item B<meta_attribute_alias($to[, $from])>
C<$from> is unspecified), so that
L<Moose/Metaclass and Trait Name Resolution> works properly.
+=item B<english_list(@items)>
+
+Given a list of scalars, turns them into a proper list in English
+("one and two", "one, two, three, and four"). This is used to help us
+make nicer error messages.
+
=back
=head1 TODO