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__;
12 *UNIVERSAL::DOES = sub {
13 my($thing, $role) = @_;
15 } unless UNIVERSAL->can('DOES');
17 $Mouse::Deprecated::deprecated = $Mouse::Deprecated::deprecated = undef; # -w
21 sub resolve_metatrait_alias {
22 return resolve_metaclass_alias( @_, trait => 1);
25 sub ensure_all_roles {
27 apply_all_roles($consumer, grep { !does_role($appicant, $_) } @_);
31 package Mouse::Meta::Module;
33 sub version { no strict 'refs'; ${shift->name.'::VERSION'} }
34 sub authority { no strict 'refs'; ${shift->name.'::AUTHORITY'} }
39 ($self->version || ()),
40 ($self->authority || ()),
44 sub role_applications { }
46 package Mouse::Meta::Role;
48 for my $modifier_type (qw/before after around/) {
49 my $modifier = "${modifier_type}_method_modifiers";
50 my $has_method_modifiers = sub{
51 my($self, $method_name) = @_;
52 my $m = $self->{$modifier}->{$method_name};
53 return $m && @{$m} != 0;
57 *{ 'has_' . $modifier_type . '_method_modifiers' } = $has_method_modifiers;
61 sub has_override_method_modifier {
62 my ($self, $method_name) = @_;
63 return exists $self->{override_method_modifiers}->{$method_name};
66 sub get_method_modifier_list {
67 my($self, $modifier_type) = @_;
69 return keys %{ $self->{$modifier_type . '_method_modifiers'} };
72 package Mouse::Meta::Method;
74 sub get_original_method { Mouse::Meta::Method->wrap(sub { }) }
76 sub associated_attribute { undef }
78 package Mouse::Util::TypeConstraints;
80 use Mouse::Util::TypeConstraints ();
82 sub export_type_constraints_as_functions { # TEST ONLY
85 foreach my $type( list_all_type_constraints() ) {
86 my $tc = find_type_constraint($type)->_compiled_type_constraint;
87 my $as = $into . '::' . $type;
90 *{$as} = sub{ &{$tc} || undef };
95 package Mouse::Meta::Attribute;
97 sub applied_traits{ $_[0]->{traits} } # TEST ONLY
98 sub has_applied_traits{ exists $_[0]->{traits} } # TEST ONLY
100 sub get_raw_value { undef } # not supported
101 sub set_raw_value { undef } # not supported
103 package Mouse::Meta::TypeConstraint;
105 sub has_message { exists $_[0]->{message} }
108 my($self, $value) = @_;
109 return $self->check($value) ? undef : $self->get_message($value);
113 my($self, $other) = @_;
114 return undef; # not supported
118 my($self, $other) = @_;
119 return undef; # not supported