2 # Moose compatible methods/functions
4 use Mouse::Util::MetaRole;
5 use Mouse::Meta::Method;
6 use Mouse::Meta::Role::Method;
8 $INC{'Mouse/Meta.pm'} = __FILE__;
9 $INC{'Mouse/Meta/Instance.pm'} = __FILE__;
10 $INC{'Mouse/Deprecated.pm'} = __FILE__;
13 *UNIVERSAL::DOES = sub {
14 my($thing, $role) = @_;
16 } unless UNIVERSAL->can('DOES');
18 $Mouse::Deprecated::deprecated = $Mouse::Deprecated::deprecated = undef; # -w
22 sub resolve_metatrait_alias {
23 return resolve_metaclass_alias( @_, trait => 1);
26 sub ensure_all_roles {
28 apply_all_roles($consumer, grep { !does_role($appicant, $_) } @_);
32 package Mouse::Meta::Module;
34 sub version { no strict 'refs'; ${shift->name.'::VERSION'} }
35 sub authority { no strict 'refs'; ${shift->name.'::AUTHORITY'} }
40 ($self->version || ()),
41 ($self->authority || ()),
45 sub role_applications { }
47 package Mouse::Meta::Class;
49 sub _immutable_options { }
51 package Mouse::Meta::Role;
53 for my $modifier_type (qw/before after around/) {
54 my $modifier = "${modifier_type}_method_modifiers";
55 my $has_method_modifiers = sub{
56 my($self, $method_name) = @_;
57 my $m = $self->{$modifier}->{$method_name};
58 return $m && @{$m} != 0;
62 *{ 'has_' . $modifier_type . '_method_modifiers' } = $has_method_modifiers;
66 sub has_override_method_modifier {
67 my ($self, $method_name) = @_;
68 return exists $self->{override_method_modifiers}->{$method_name};
71 sub get_method_modifier_list {
72 my($self, $modifier_type) = @_;
74 return keys %{ $self->{$modifier_type . '_method_modifiers'} };
77 package Mouse::Meta::Method;
79 sub get_original_method { Mouse::Meta::Method->wrap(sub { }) }
81 sub associated_attribute { undef }
83 package Mouse::Meta::Method::Constructor;
85 sub _generate_BUILDALL { }
87 package Mouse::Meta::Method::Constructor::XS;
89 sub _generate_BUILDALL { }
91 package Mouse::Util::TypeConstraints;
93 use Mouse::Util::TypeConstraints ();
95 sub export_type_constraints_as_functions { # TEST ONLY
98 foreach my $type( list_all_type_constraints() ) {
99 my $tc = find_type_constraint($type)->_compiled_type_constraint;
100 my $as = $into . '::' . $type;
103 *{$as} = sub{ &{$tc} || undef };
108 package Mouse::Meta::Attribute;
110 sub applied_traits{ $_[0]->{traits} } # TEST ONLY
111 sub has_applied_traits{ exists $_[0]->{traits} } # TEST ONLY
113 sub get_raw_value { undef } # not supported
114 sub set_raw_value { undef } # not supported
116 package Mouse::Meta::TypeConstraint;
118 sub has_message { exists $_[0]->{message} }
121 my($self, $value) = @_;
122 return $self->check($value) ? undef : $self->get_message($value);
126 my($self, $other) = @_;
127 return undef; # not supported
131 my($self, $other) = @_;
132 return undef; # not supported