Codebase list libmoose-perl / 02bcc76
* New upstream release. * Bump (build-)dep on libclass-mop-perl to >= 1.04. * Add (build-)dep on libpackage-deprecationmanager-perl. * debian/control: Update Breaks field. * Bump Standards-Version to 3.9.0 (no changes). Ansgar Burchardt 13 years ago
102 changed file(s) with 866 addition(s) and 406 deletion(s). Raw diff Collapse all Expand all
00 Also see Moose::Manual::Delta for more details of, and workarounds
11 for, noteworthy changes.
2
3 1.09 Tue, Jul 25, 2010
4
5 [API CHANGES]
6
7 * You can no longer pass "coerce => 1" for an attribute unless its type
8 constraint has a coercion defined. Doing so will issue a deprecation
9 warning. (Dave Rolsky)
10
11 * Previously, '+foo' only allowed a specific set of options to be
12 overridden, which made it impossible to change attribute options related
13 to extensions. Now we blacklist some options, and anything else is
14 allowed. (doy, Tuomas Jormola)
15
16 * Most features which have been declared deprecated now issue a warning using
17 Moose::Deprecated. Warnings are issued once per calling package, not
18 repeatedly. See Moose::Deprecated for information on how you can shut
19 these warnings up entirely. Note that deprecated features will eventually
20 be removed, so shutting up the warnings may not be the best idea. (Dave
21 Rolsky)
22
23 * Removed the long-deprecated Moose::Meta::Role->alias_method method. (Dave
24 Rolsky).
25
26 [NEW FEATURES]
27
28 * We no longer unimport strict and warnings when Moose, Moose::Role, or
29 Moose::Exporter are unimported. Doing this was broken if the user
30 explicitly loaded strict and warnings themself, and the results could be
31 generally surprising. We decided that it was best to err on the side of
32 safety and leave these on. Reported by David Wheeler. RT #58310. (Dave
33 Rolsky)
34
35 * New with_traits helper function in Moose::Util. (doy)
36
37 [BUG FIXES]
38
39 * Accessors will no longer be inlined if the instance metaclass isn't
40 inlinable. (doy)
41
42 * Use Perl 5.10's new recursive regex features, if possible, for the type
43 constraint parser. (doy, nothingmuch)
44
45 [ENHANCEMENTS]
46
47 * Attributes now warn if their accessors overwrite a locally defined
48 function (not just method). (doy)
49
50 [OTHER]
51
52 * Bump our required perl version to 5.8.3, since earlier versions fail tests
53 and aren't easily installable/testable.
254
355 1.08 Tue, Jun 15, 2010
456
3939 lib/Moose/Cookbook/Snack/Keywords.pod
4040 lib/Moose/Cookbook/Snack/Types.pod
4141 lib/Moose/Cookbook/Style.pod
42 lib/Moose/Deprecated.pm
4243 lib/Moose/Error/Confess.pm
4344 lib/Moose/Error/Croak.pm
4445 lib/Moose/Error/Default.pm
188189 t/020_attributes/019_attribute_lazy_initializer.t
189190 t/020_attributes/020_trigger_and_coerce.t
190191 t/020_attributes/021_method_generation_rules.t
191 t/020_attributes/022_legal_options_for_inheritance.t
192 t/020_attributes/022_illegal_options_for_inheritance.t
192193 t/020_attributes/023_attribute_names.t
193194 t/020_attributes/024_attribute_traits_parameterized.t
194195 t/020_attributes/025_chained_coercion.t
199200 t/020_attributes/030_non_alpha_attr_names.t
200201 t/020_attributes/031_delegation_and_modifiers.t
201202 t/020_attributes/032_delegation_arg_aliasing.t
203 t/020_attributes/033_accessor_inlining.t
204 t/020_attributes/034_bad_coerce.t
202205 t/030_roles/001_meta_role.t
203206 t/030_roles/002_role.t
204207 t/030_roles/003_apply_role.t
347350 t/100_bugs/027_constructor_object_overload.t
348351 t/100_bugs/028_apply_role_to_one_instance_only.t
349352 t/100_bugs/029_instance_application_role_args.t
353 t/100_bugs/030_coerce_without_coercion.t
350354 t/200_examples/001_example.t
351355 t/200_examples/002_example_Moose_POOP.t
352356 t/200_examples/003_example.t
378382 t/400_moose_util/006_create_alias.t
379383 t/400_moose_util/007_apply_roles.t
380384 t/400_moose_util/008_method_mod_args.t
385 t/400_moose_util/009_with_traits.t
381386 t/500_test_moose/001_test_moose.t
382387 t/500_test_moose/002_test_moose_does_ok.t
383388 t/500_test_moose/003_test_moose_has_attribute_ok.t
88 configure_requires:
99 ExtUtils::MakeMaker: 6.42
1010 distribution_type: module
11 generated_by: 'Module::Install version 0.99'
11 generated_by: 'Module::Install version 1.00'
1212 license: perl
1313 meta-spec:
1414 url: http://module-build.sourceforge.net/META-spec-v1.4.html
2121 - xt
2222 requires:
2323 Carp: 0
24 Class::MOP: 1.02
24 Class::MOP: 1.04
2525 Data::OptList: 0
2626 List::MoreUtils: 0.12
27 Package::DeprecationManager: 0.04
2728 Scalar::Util: 1.19
2829 Sub::Exporter: 0.980
2930 Sub::Name: 0
3031 Task::Weaken: 0
3132 Try::Tiny: 0.02
32 perl: 5.8.1
33 perl: 5.8.3
3334 resources:
3435 license: http://dev.perl.org/licenses/
3536 repository: git://git.moose.perl.org/Moose.git
36 version: 1.08
37 version: 1.09
3738 x_authority: cpan:STEVAN
11 use warnings;
22 use inc::Module::Install 0.98;
33 use Module::Install::AuthorRequires;
4 use 5.008001;
4 use 5.008003;
55
66 check_broken_extratests();
77 check_conflicts();
88
99 name 'Moose';
10 perl_version '5.008001';
10 perl_version '5.008003';
1111 all_from 'lib/Moose.pm';
1212 license 'perl';
1313
1414 requires 'Carp';
15 requires 'Class::MOP' => '1.02';
16 requires 'Data::OptList' => '0';
17 requires 'List::MoreUtils' => '0.12';
18 requires 'Scalar::Util' => '1.19';
19 requires 'Sub::Exporter' => '0.980';
20 requires 'Sub::Name' => '0';
21 requires 'Task::Weaken' => '0';
22 requires 'Try::Tiny' => '0.02';
15 requires 'Class::MOP' => '1.04';
16 requires 'Data::OptList' => '0';
17 requires 'List::MoreUtils' => '0.12';
18 requires 'Package::DeprecationManager' => '0.04';
19 requires 'Scalar::Util' => '1.19';
20 requires 'Sub::Exporter' => '0.980';
21 requires 'Sub::Name' => '0';
22 requires 'Task::Weaken' => '0';
23 requires 'Try::Tiny' => '0.02';
2324
2425 test_requires 'Test::More' => '0.88';
2526 test_requires 'Test::Exception' => '0.27';
2627
27 author_requires 'Test::Inline';
2828 author_requires 'File::Find::Rule';
2929 author_requires 'Module::Info';
30 author_requires 'Test::Inline';
31 author_requires 'Test::NoTabs';
32 author_requires 'Test::Output';
33 author_requires 'Test::Pod::Coverage';
3034 author_requires 'Test::Spelling';
31 author_requires 'Test::Pod::Coverage';
32 author_requires 'Test::NoTabs';
3335
3436 if ( is_maintainer() ) {
3537 system( $^X, 'author/extract-inline-tests' );
4749 # before a release.
4850 sub check_conflicts {
4951 my %conflicts = (
50 'Devel::REPL' => '1.003008',
51 'Fey::ORM' => '0.23',
52 'Catalyst' => '5.80017',
53 'MooseX::Aliases' => '0.07',
54 'MooseX::AttributeHelpers' => '0.22',
55 'MooseX::Attribute::Prototype' => '0.10',
56 'MooseX::ClassAttribute' => '0.09',
57 'MooseX::MethodAttributes' => '0.18',
58 'MooseX::NonMoose' => '0.07',
59 'MooseX::Params::Validate' => '0.05',
60 'MooseX::Role::Cmd' => '0.06',
61 'MooseX::Role::WithOverloading' => '0.04',
62 'MooseX::Singleton' => '0.19',
63 'MooseX::StrictConstructor' => '0.07',
64 'MooseX::Types' => '0.19',
65 'Pod::Elemental' => '0.093280',
66 'namespace::autoclean' => '0.08',
67 'KiokuDB' => '0.41',
52 'Catalyst' => '5.80017',
53 'Devel::REPL' => '1.003008',
54 'Fey::ORM' => '0.23',
55 'File::ChangeNotify' => '0.15',
56 'KiokuDB' => '0.41',
57 'MooseX::Aliases' => '0.07',
58 'MooseX::AttributeHelpers' => '0.22',
59 'MooseX::AttributeInflate' => '0.02',
60 'MooseX::Attribute::Prototype' => '0.10',
61 'MooseX::ClassAttribute' => '0.13',
62 'MooseX::FollowPBP' => '0.02',
63 'MooseX::HasDefaults' => '0.02',
64 'MooseX::InstanceTracking' => '0.04',
65 'MooseX::LazyRequire' => '0.05',
66 'MooseX::MethodAttributes' => '0.22',
67 'MooseX::NonMoose' => '0.13',
68 'MooseX::Params::Validate' => '0.05',
69 'MooseX::Role::Cmd' => '0.06',
70 'MooseX::Role::WithOverloading' => '0.07',
71 'MooseX::SemiAffordanceAccessor' => '0.05',
72 'MooseX::Singleton' => '0.22',
73 'MooseX::StrictConstructor' => '0.08',
74 'MooseX::Types' => '0.19',
75 'MooseX::UndefTolerant' => '0.04',
76 'namespace::autoclean' => '0.08',
77 'Pod::Elemental' => '0.093280',
6878 );
6979
7080 my $found = 0;
0 Moose version 1.08
0 Moose version 1.09
11 ===========================
22
33 See the individual module documentation for more information
0 libmoose-perl (1.09-1) unstable; urgency=low
1
2 * New upstream release.
3 * Bump (build-)dep on libclass-mop-perl to >= 1.04.
4 * Add (build-)dep on libpackage-deprecationmanager-perl.
5 * debian/control: Update Breaks field.
6 * Bump Standards-Version to 3.9.0 (no changes).
7
8 -- Ansgar Burchardt <ansgar@43-1.org> Mon, 26 Jul 2010 07:59:12 +0900
9
010 libmoose-perl (1.08-1) unstable; urgency=low
111
212 * New upstream release
00 Source: libmoose-perl
11 Section: perl
22 Priority: optional
3 Build-Depends: debhelper (>= 7), libclass-mop-perl (>= 1.02),
3 Build-Depends: debhelper (>= 7), libclass-mop-perl (>= 1.04),
44 libdata-optlist-perl, libdatetime-format-mysql-perl, libdbm-deep-perl,
55 libio-string-perl, liblist-moreutils-perl (>= 0.12), liblocale-us-perl,
66 libmodule-refresh-perl, libparams-coerce-perl, libregexp-common-perl,
77 libsub-exporter-perl (>= 0.980), libsub-name-perl, libtask-weaken-perl,
88 libtest-deep-perl, libtest-exception-perl (>= 0.27), libtest-output-perl,
99 libtest-warn-perl, libtry-tiny-perl, liburi-perl, libwww-perl,
10 perl (>= 5.10.0), perl (>= 5.10.1) | libtest-simple-perl (>= 0.88)
10 perl (>= 5.10.0), perl (>= 5.10.1) | libtest-simple-perl (>= 0.88),
11 libpackage-deprecationmanager-perl
1112 Maintainer: Debian Perl Group <pkg-perl-maintainers@lists.alioth.debian.org>
1213 Uploaders: Krzysztof Krzyżaniak (eloy) <eloy@debian.org>,
1314 Salvatore Bonaccorso <salvatore.bonaccorso@gmail.com>,
1617 Jose Luis Rivas <ghostbar38@gmail.com>, Ryan Niebur <ryan@debian.org>,
1718 Niko Tyni <ntyni@iki.fi>, Ansgar Burchardt <ansgar@43-1.org>,
1819 Jonathan Yu <jawnsy@cpan.org>, Iulian Udrea <iulian@ubuntu.com>
19 Standards-Version: 3.8.4
20 Standards-Version: 3.9.0
2021 Homepage: http://search.cpan.org/dist/Moose/
2122 Vcs-Svn: svn://svn.debian.org/pkg-perl/trunk/libmoose-perl/
2223 Vcs-Browser: http://svn.debian.org/viewsvn/pkg-perl/trunk/libmoose-perl/
2425 Package: libmoose-perl
2526 Architecture: any
2627 Depends: ${misc:Depends}, ${perl:Depends}, ${shlibs:Depends},
27 libclass-mop-perl (>= 1.02), libdata-optlist-perl,
28 libclass-mop-perl (>= 1.04), libdata-optlist-perl,
2829 liblist-moreutils-perl, libsub-exporter-perl (>= 0.980),
2930 libsub-name-perl, libtask-weaken-perl, libtry-tiny-perl,
30 perl (>= 5.10.0) | libscalar-list-utils-perl (>= 1.19)
31 perl (>= 5.10.0) | libscalar-list-utils-perl (>= 1.19),
32 libpackage-deprecationmanager-perl
3133 Breaks: libcatalyst-perl (<< 5.80017+), libdevel-repl-perl (<< 1.003008+),
32 libfey-orm-perl (<< 0.23+), libmoosex-attributehelpers-perl (<< 0.21+),
33 libmoosex-classattribute-perl (<< 0.09+), libmoosex-methodattributes (<< 0.15+),
34 libmoosex-nonmoose-perl (<< 0.07+), libmoosex-params-validate-perl (<< 0.05+),
35 libmoosex-singleton-perl (<< 0.19+),
36 libmoosex-strictconstructor-perl (<< 0.07+), libmoosex-types-perl (<< 0.19+),
34 libfey-orm-perl (<< 0.23+), libfile-changenotify-perl (<< 0.16),
35 libmoosex-attributehelpers-perl (<< 0.23), libmoosex-lazyrequire-perl (<< 0.06),
36 libmoosex-classattribute-perl (<< 0.09+), libmoosex-methodattributes (<< 0.24),
37 libmoosex-nonmoose-perl (<< 0.13+), libmoosex-params-validate-perl (<< 0.05+),
38 libmoosex-role-withoverloading-perl (<< 0.08),
39 libmoosex-semiaffordanceaccessor-perl (<< 0.06),
40 libmoosex-singleton-perl (<< 0.23),
41 libmoosex-strictconstructor-perl (<< 0.09), libmoosex-types-perl (<< 0.19+),
3742 libnamespace-autoclean-perl (<< 0.08+), libpod-elemental-perl (<< 0.093280+)
3843 Description: modern Perl object system framework
3944 Moose, it's the new Camel. Moose is an extension of the existing Perl 5 object
33 use strict 'vars';
44 use vars qw{$VERSION};
55 BEGIN {
6 $VERSION = '0.99';
6 $VERSION = '1.00';
77 }
88
99 # Suspend handler for "redefined" warnings
88
99 use vars qw{$VERSION @ISA $ISCORE};
1010 BEGIN {
11 $VERSION = '0.99';
11 $VERSION = '1.00';
1212 @ISA = 'Module::Install::Base';
1313 $ISCORE = 1;
1414 }
55
66 use vars qw{$VERSION @ISA $ISCORE};
77 BEGIN {
8 $VERSION = '0.99';
8 $VERSION = '1.00';
99 @ISA = 'Module::Install::Base';
1010 $ISCORE = 1;
1111 }
77
88 use vars qw{$VERSION @ISA $ISCORE};
99 BEGIN {
10 $VERSION = '0.99';
10 $VERSION = '1.00';
1111 @ISA = 'Module::Install::Base';
1212 $ISCORE = 1;
1313 }
55
66 use vars qw{$VERSION @ISA $ISCORE};
77 BEGIN {
8 $VERSION = '0.99';
8 $VERSION = '1.00';
99 @ISA = 'Module::Install::Base';
1010 $ISCORE = 1;
1111 }
55
66 use vars qw{$VERSION @ISA $ISCORE};
77 BEGIN {
8 $VERSION = '0.99';
8 $VERSION = '1.00';
99 @ISA = 'Module::Install::Base';
1010 $ISCORE = 1;
1111 }
55
66 use vars qw{$VERSION @ISA $ISCORE};
77 BEGIN {
8 $VERSION = '0.99';
8 $VERSION = '1.00';
99 @ISA = qw{Module::Install::Base};
1010 $ISCORE = 1;
1111 }
3030 # This is not enforced yet, but will be some time in the next few
3131 # releases once we can make sure it won't clash with custom
3232 # Module::Install extensions.
33 $VERSION = '0.99';
33 $VERSION = '1.00';
3434
3535 # Storage for the pseudo-singleton
3636 $MAIN = undef;
229229 sub new {
230230 my ($class, %args) = @_;
231231
232 delete $INC{'FindBin.pm'};
233 require FindBin;
232 delete $INC{'FindBin.pm'};
233 {
234 # to suppress the redefine warning
235 local $SIG{__WARN__} = sub {};
236 require FindBin;
237 }
234238
235239 # ignore the prefix on extension modules built from top level.
236240 my $base_path = Cwd::abs_path($FindBin::Bin);
0 package Moose::Deprecated;
1
2 use strict;
3 use warnings;
4
5 our $VERSION = '1.09';
6 $VERSION = eval $VERSION;
7 our $AUTHORITY = 'cpan:STEVAN';
8
9 use Package::DeprecationManager -deprecations => {
10 'coerce without coercion' => '1.08',
11 'pre-0.94 MetaRole API' => '0.93',
12 'Role type' => '0.84',
13 'subtype without sugar' => '0.72',
14 'type without sugar' => '0.72',
15 'Moose::init_meta' => '0.56',
16 },
17 -ignore => [
18 qw( Moose
19 Moose::Exporter
20 Moose::Meta::Attribute
21 Moose::Meta::Class
22 Moose::Util::MetaRole
23 )
24 ],
25 ;
26
27 1;
28
29 __END__
30
31 =pod
32
33 =head1 NAME
34
35 Moose::Deprecated - Manages deprecation warnings for Moose
36
37 =head1 DESCRIPTION
38
39 use Moose::Deprecated -api_version => $version;
40
41 =head1 FUNCTIONS
42
43 This module manages deprecation warnings for features that have been
44 deprecated in Moose.
45
46 If you specify C<< -api_version => $version >>, you can use deprecated features
47 without warnings. Note that this special treatment is limited to the package
48 that loads C<Class::MOP::Deprecated>.
49
50 =head1 AUTHORS
51
52 Dave Rolsky E<lt>autarch@urth.orgE<gt>
53
54 =head1 COPYRIGHT AND LICENSE
55
56 Copyright 2006-2010 by Infinity Interactive, Inc.
57
58 L<http://www.iinteractive.com>
59
60 This library is free software; you can redistribute it and/or modify
61 it under the same terms as Perl itself.
62
63 =cut
22 use strict;
33 use warnings;
44
5 our $VERSION = '1.08';
5 our $VERSION = '1.09';
66 $VERSION = eval $VERSION;
77 our $AUTHORITY = 'cpan:STEVAN';
88
22 use strict;
33 use warnings;
44
5 our $VERSION = '1.08';
5 our $VERSION = '1.09';
66 $VERSION = eval $VERSION;
77 our $AUTHORITY = 'cpan:STEVAN';
88
22 use strict;
33 use warnings;
44
5 our $VERSION = '1.08';
5 our $VERSION = '1.09';
66 $VERSION = eval $VERSION;
77 our $AUTHORITY = 'cpan:STEVAN';
88
22 use strict;
33 use warnings;
44
5 our $VERSION = '1.08';
5 our $VERSION = '1.09';
66 our $XS_VERSION = $VERSION;
77 $VERSION = eval $VERSION;
88 our $AUTHORITY = 'cpan:STEVAN';
99
1010 use Class::MOP;
1111 use List::MoreUtils qw( first_index uniq );
12 use Moose::Deprecated;
1213 use Moose::Util::MetaRole;
1314 use Sub::Exporter 0.980;
1415 use Sub::Name qw(subname);
474475 $export_recorder,
475476 $is_reexport,
476477 );
477 strict->unimport;
478 warnings->unimport;
479478 };
480479 }
481480
546545
547546 return unless Class::MOP::class_of( $options{for_class} );
548547
549 Moose::Util::MetaRole::apply_metaroles(
550 for => $options{for_class},
551 %new_style_roles,
552 %old_style_roles,
553 );
548 if ( %new_style_roles || %old_style_roles ) {
549 Moose::Util::MetaRole::apply_metaroles(
550 for => $options{for_class},
551 %new_style_roles,
552 %old_style_roles,
553 );
554 }
554555
555556 Moose::Util::MetaRole::apply_base_class_roles(
556557 for_class => $options{for_class},
566567 sub import {
567568 strict->import;
568569 warnings->import;
569 }
570
571 sub unimport {
572 strict->unimport;
573 warnings->unimport;
574570 }
575571
576572 1;
651647
652648 If you pass any parameters for L<Moose::Util::MetaRole>, this method will
653649 generate an C<init_meta> for you as well (see below for details). This
654 C<init_meta> will call C<Moose::Util::MetaRole::apply_metaclass_roles> and
650 C<init_meta> will call C<Moose::Util::MetaRole::apply_metaroles> and
655651 C<Moose::Util::MetaRole::apply_base_class_roles> as needed.
656652
657653 Note that if any of these methods already exist, they will not be
697693
698694 You can also provide parameters for C<Moose::Util::MetaRole::apply_metaroles>
699695 and C<Moose::Util::MetaRole::base_class_roles>. Specifically, valid parameters
700 are "class_metaroles", "role_metaroles", and "base_object_roles".
696 are "class_metaroles", "role_metaroles", and "base_class_roles".
701697
702698 =item B<< Moose::Exporter->build_import_methods(...) >>
703699
1414
1515 =head2 C<namespace::autoclean> and immutabilize
1616
17 We recommend that you remove the Moose sugar and end your Moose class
17 We recommend that you remove the Moose sugar and end your Moose class
1818 definitions by making your class immutable.
1919
2020 package Person;
3333 The C<use namespace::autoclean> bit is simply good code hygiene, as it removes
3434 imported symbols from you class's namespace at the end of your package's
3535 compile cycle, including Moose keywords. Once the class has been
36 built, these keywords are not needed needed. The C<make_immutable>
36 built, these keywords are not needed. The C<make_immutable>
3737 call allows Moose to speed up a lot of things, most notably object
3838 construction. The trade-off is that you can no longer change the class
3939 definition.
4040
41 C<no Moose;> may be used to unimport only Moose's imported symbols.
42 L<namespace::clean> provides finer-grained control than L<namespace::autoclean>.
41 You can also write C<no Moose> to unimport only Moose's imported symbols. The
42 L<namespace::clean> module is another alternative, providing finer-grained
43 control than L<namespace::autoclean>.
4344
4445 =head2 Never override C<new>
4546
1414 feature. If you encounter a problem and have a solution but don't see
1515 it documented here, or think we missed an important feature, please
1616 send us a patch.
17
18 =head1 1.09
19
20 =over 4
21
22 =item All deprecated features now warn
23
24 Previously, deprecation mostly consisted of simply saying "X is deprecated" in
25 the Changes file. We were not very consistent about actually warning. Now, all
26 deprecated features still present in Moose actually give a warning. The
27 warning is issued once per calling package. See L<Moose::Deprecated> for more
28 details.
29
30 =item You cannot pass C<< coerce => 1 >> unless the attribute's type constraint has a coercion
31
32 Previously, this was accepted, and it sort of worked, except that if you
33 attempted to set the attribute after the object was created, you would get a
34 runtime error.
35
36 Now you will get an error when you attempt to define the attribute.
37
38 =item C<no Moose>, C<no Moose::Role>, and C<no Moose::Exporter> no longer unimport strict and warnings
39
40 This change was made in 1.05, and has now been reverted. We don't know if the
41 user has explicitly loaded strict or warnings on their own, and unimporting
42 them is just broken in that case.
43
44 =item Reversed logic when defining which options can be changed
45
46 L<Moose::Meta::Attribute> now allows all options to be changed in an
47 overridden attribute. The previous behaviour required each option to be
48 whitelisted using the C<legal_options_for_inheritance> method. This method has
49 been removed, and there is a new method, C<illegal_options_for_inheritance>,
50 which can now be used to prevent certain options from being changeable.
51
52 In addition, we only throw an error if the illegal option is actually
53 changed. If the superclass didn't specify this option at all when defining the
54 attribute, the subclass version can still add it as an option.
55
56 Example of overriding this in an attribute trait:
57
58 package Bar::Meta::Attribute;
59 use Moose::Role;
60
61 has 'my_illegal_option' => (
62 isa => 'CodeRef',
63 is => 'rw',
64 );
65
66 around illegal_options_for_inheritance => sub {
67 return ( shift->(@_), qw/my_illegal_option/ );
68 };
69
70 =back
1771
1872 =head1 1.05
1973
1010 released on a schedule. Releases happen as new features and bug fixes
1111 are required.
1212
13 There have been to date, 98 releases of Moose over just under four
14 years. This is an average of a release every two weeks.
13 Moose has historically been released fairly often, and most releases include
14 just a few features or bug fixes.
1515
1616 =head1 DEPRECATION POLICY
1717
1919 compatibility.
2020
2121 Major deprecations or API changes are first documented in the Changes
22 file as well as in L<Moose::Manual::Delta|Moose::Manual::Delta>
22 file as well as in L<Moose::Manual::Delta>.
2323
2424 Moose then attempts to warn for deprecated features and API changes for
2525 a reasonable number of releases before breaking any tested API.
5656 =head1 CONTRIBUTING
5757
5858 Moose has an open contribution policy. Anybody is welcome to submit a
59 patch. Please see
60 L<Moose::Manual::Contributing|Moose::Manual::Contributing> for more
61 details.
59 patch. Please see L<Moose::Manual::Contributing> for more details.
6260
6361 =cut
197197 application.
198198
199199 Once you're doing this, you should almost certainly look at the
200 L<MooseX::Types> extension which allows easy declaration of type libraries
201 and can export your types as perl constants so that you can refer to them
202 as just
200 L<MooseX::Types> module. This module makes it easy to create a "type library"
201 module, which can export your types as perl constants.
203202
204203 has 'counter' => (is => 'rw', isa => PositiveInt);
205204
206 rather than needing to fully qualify them everywhere. It also allows
205 This lets you use a short name rather than needing to fully qualify the name
206 everywhere. It also allows you to write easily create parameterized types:
207207
208208 has 'counts' => (is => 'ro', isa => HashRef[PositiveInt]);
209209
210 and similarly for the union and other syntax discussed below, which
211 will compile time check your use of names and is generally more robust
212 than the string type parsing for complex cases.
210 This module will check your names at compile time, and is generally more
211 robust than the string type parsing for complex cases.
213212
214213 =head1 COERCION
215214
426425 C<MyApp::Types>. Second, load this module in all of your other
427426 modules.
428427
429 If you are still having load order problems, you can make use of the
430 C<find_type_constraint> function exported by
431 L<Moose::Util::TypeConstraints>:
432
433 class_type('MyApp::User')
434 unless find_type_constraint('MyApp::User');
435
436 This sort of "find or create" logic is simple to write, and will let
437 you work around load order issues.
438
439428 =head1 AUTHOR
440429
441430 Dave Rolsky E<lt>autarch@urth.orgE<gt>
33 use List::Util;
44 use List::MoreUtils;
55
6 our $VERSION = '1.08';
6 our $VERSION = '1.09';
77 $VERSION = eval $VERSION;
88 our $AUTHORITY = 'cpan:STEVAN';
99
11 package Moose::Meta::Attribute::Native::MethodProvider::Bool;
22 use Moose::Role;
33
4 our $VERSION = '1.08';
4 our $VERSION = '1.09';
55 $VERSION = eval $VERSION;
66 our $AUTHORITY = 'cpan:STEVAN';
77
00 package Moose::Meta::Attribute::Native::MethodProvider::Code;
11 use Moose::Role;
22
3 our $VERSION = '1.08';
3 our $VERSION = '1.09';
44 $VERSION = eval $VERSION;
55 our $AUTHORITY = 'cpan:STEVAN';
66
11 package Moose::Meta::Attribute::Native::MethodProvider::Counter;
22 use Moose::Role;
33
4 our $VERSION = '1.08';
4 our $VERSION = '1.09';
55 $VERSION = eval $VERSION;
66 our $AUTHORITY = 'cpan:STEVAN';
77
00 package Moose::Meta::Attribute::Native::MethodProvider::Hash;
11 use Moose::Role;
22
3 our $VERSION = '1.08';
3 our $VERSION = '1.09';
44 $VERSION = eval $VERSION;
55 our $AUTHORITY = 'cpan:STEVAN';
66
00 package Moose::Meta::Attribute::Native::MethodProvider::String;
11 use Moose::Role;
22
3 our $VERSION = '1.08';
3 our $VERSION = '1.09';
44 $VERSION = eval $VERSION;
55 our $AUTHORITY = 'cpan:STEVAN';
66
11 package Moose::Meta::Attribute::Native::Trait::Array;
22 use Moose::Role;
33
4 our $VERSION = '1.08';
4 our $VERSION = '1.09';
55 $VERSION = eval $VERSION;
66 our $AUTHORITY = 'cpan:STEVAN';
77
11 use Moose::Role;
22 use Moose::Meta::Attribute::Native::MethodProvider::Bool;
33
4 our $VERSION = '1.08';
4 our $VERSION = '1.09';
55 $VERSION = eval $VERSION;
66 our $AUTHORITY = 'cpan:STEVAN';
77
11 use Moose::Role;
22 use Moose::Meta::Attribute::Native::MethodProvider::Code;
33
4 our $VERSION = '1.08';
4 our $VERSION = '1.09';
55 $VERSION = eval $VERSION;
66 our $AUTHORITY = 'cpan:STEVAN';
77
11 package Moose::Meta::Attribute::Native::Trait::Counter;
22 use Moose::Role;
33
4 our $VERSION = '1.08';
4 our $VERSION = '1.09';
55 $VERSION = eval $VERSION;
66 our $AUTHORITY = 'cpan:STEVAN';
77
11 package Moose::Meta::Attribute::Native::Trait::Hash;
22 use Moose::Role;
33
4 our $VERSION = '1.08';
4 our $VERSION = '1.09';
55 $VERSION = eval $VERSION;
66 our $AUTHORITY = 'cpan:STEVAN';
77
00 package Moose::Meta::Attribute::Native::Trait::Number;
11 use Moose::Role;
22
3 our $VERSION = '1.08';
3 our $VERSION = '1.09';
44 $VERSION = eval $VERSION;
55 our $AUTHORITY = 'cpan:STEVAN';
66
00 package Moose::Meta::Attribute::Native::Trait::String;
11 use Moose::Role;
22
3 our $VERSION = '1.08';
3 our $VERSION = '1.09';
44 $VERSION = eval $VERSION;
55 our $AUTHORITY = 'cpan:STEVAN';
66
22 use Moose::Role;
33 use Moose::Util::TypeConstraints;
44
5 our $VERSION = '1.08';
5 our $VERSION = '1.09';
66 $VERSION = eval $VERSION;
77 our $AUTHORITY = 'cpan:STEVAN';
88
00 package Moose::Meta::Attribute::Native;
11
2 our $VERSION = '1.08';
2 our $VERSION = '1.09';
33 $VERSION = eval $VERSION;
44 our $AUTHORITY = 'cpan:STEVAN';
55
88 use Try::Tiny;
99 use overload ();
1010
11 our $VERSION = '1.08';
11 our $VERSION = '1.09';
1212 our $AUTHORITY = 'cpan:STEVAN';
1313
14 use Moose::Deprecated;
1415 use Moose::Meta::Method::Accessor;
1516 use Moose::Meta::Method::Delegation;
1617 use Moose::Util ();
130131
131132 # ...
132133
133 my @legal_options_for_inheritance = qw(
134 default coerce required
135 documentation lazy handles
136 builder type_constraint
137 definition_context
138 lazy_build weak_ref
139 );
140
141 sub legal_options_for_inheritance { @legal_options_for_inheritance }
134 # method-generating options shouldn't be overridden
135 sub illegal_options_for_inheritance {
136 qw(is reader writer accessor clearer predicate)
137 }
142138
143139 # NOTE/TODO
144140 # This method *must* be able to handle
157153 sub clone_and_inherit_options {
158154 my ($self, %options) = @_;
159155
160 my %copy = %options;
161
162 my %actual_options;
163
164156 # NOTE:
165157 # we may want to extends a Class::MOP::Attribute
166158 # in which case we need to be able to use the
168160 # been here. But we allows Moose::Meta::Attribute
169161 # instances to changes them.
170162 # - SL
171 my @legal_options = $self->can('legal_options_for_inheritance')
172 ? $self->legal_options_for_inheritance
173 : @legal_options_for_inheritance;
174
175 foreach my $legal_option (@legal_options) {
176 if (exists $options{$legal_option}) {
177 $actual_options{$legal_option} = $options{$legal_option};
178 delete $options{$legal_option};
179 }
180 }
163 my @illegal_options = $self->can('illegal_options_for_inheritance')
164 ? $self->illegal_options_for_inheritance
165 : ();
166
167 my @found_illegal_options = grep { exists $options{$_} && exists $self->{$_} ? $_ : undef } @illegal_options;
168 (scalar @found_illegal_options == 0)
169 || $self->throw_error("Illegal inherited options => (" . (join ', ' => @found_illegal_options) . ")", data => \%options);
181170
182171 if ($options{isa}) {
183172 my $type_constraint;
190179 || $self->throw_error("Could not find the type constraint '" . $options{isa} . "'", data => $options{isa});
191180 }
192181
193 $actual_options{type_constraint} = $type_constraint;
194 delete $options{isa};
182 $options{type_constraint} = $type_constraint;
195183 }
196184
197185 if ($options{does}) {
205193 || $self->throw_error("Could not find the type constraint '" . $options{does} . "'", data => $options{does});
206194 }
207195
208 $actual_options{type_constraint} = $type_constraint;
209 delete $options{does};
196 $options{type_constraint} = $type_constraint;
210197 }
211198
212199 # NOTE:
214201 # so we can ignore it for them.
215202 # - SL
216203 if ($self->can('interpolate_class')) {
217 ( $actual_options{metaclass}, my @traits ) = $self->interpolate_class(\%options);
204 ( $options{metaclass}, my @traits ) = $self->interpolate_class(\%options);
218205
219206 my %seen;
220207 my @all_traits = grep { $seen{$_}++ } @{ $self->applied_traits || [] }, @traits;
221 $actual_options{traits} = \@all_traits if @all_traits;
222
223 delete @options{qw(metaclass traits)};
224 }
225
226 (scalar keys %options == 0)
227 || $self->throw_error("Illegal inherited options => (" . (join ', ' => keys %options) . ")", data => \%options);
228
229
230 $self->clone(%actual_options);
208 $options{traits} = \@all_traits if @all_traits;
209 }
210
211 $self->clone(%options);
231212 }
232213
233214 sub clone {
321302 || $class->throw_error("You cannot have coercion without specifying a type constraint on attribute ($name)", data => $options);
322303 $class->throw_error("You cannot have a weak reference to a coerced value on attribute ($name)", data => $options)
323304 if $options->{weak_ref};
305
306 unless ( $options->{type_constraint}->has_coercion ) {
307 my $type = $options->{type_constraint}->name;
308
309 Moose::Deprecated::deprecated(
310 feature => 'coerce without coercion',
311 message =>
312 "You cannot coerce an attribute ($name) unless its type ($type) has a coercion"
313 );
314 }
324315 }
325316
326317 if (exists $options->{trigger}) {
435426
436427 return $meta_instance->set_slot_value($instance, $slot_name, $value)
437428 unless $self->has_initializer;
438
439 my ($type_constraint, $can_coerce);
440 if ($self->has_type_constraint) {
441 $type_constraint = $self->type_constraint;
442 $can_coerce = ($self->should_coerce && $type_constraint->has_coercion);
443 }
444429
445430 my $callback = sub {
446431 my $val = $self->_coerce_and_verify( shift, $instance );;
574559 . "an accessor"
575560 );
576561 }
562 if (!$self->associated_class->has_method($accessor)
563 && $self->associated_class->has_package_symbol('&' . $accessor)) {
564 Carp::cluck(
565 "You are overwriting a locally defined function ($accessor) with "
566 . "an accessor"
567 );
568 }
577569 $self->SUPER::_process_accessors(@_);
578570 }
579571
737729
738730 return $val unless $self->has_type_constraint;
739731
740 my $type_constraint = $self->type_constraint;
741 if ($self->should_coerce && $type_constraint->has_coercion) {
742 $val = $type_constraint->coerce($val);
743 }
732 $val = $self->type_constraint->coerce($val)
733 if $self->should_coerce && $self->type_constraint->has_coercion;
744734
745735 $self->verify_against_type_constraint($val, instance => $instance);
746736
10291019 the C<clone> method.
10301020
10311021 One of its main tasks is to make sure that the C<%options> provided
1032 only includes the options returned by the
1033 C<legal_options_for_inheritance> method.
1034
1035 =item B<< $attr->legal_options_for_inheritance >>
1036
1037 This returns a whitelist of options that can be overridden in a
1022 does not include the options returned by the
1023 C<illegal_options_for_inheritance> method.
1024
1025 =item B<< $attr->illegal_options_for_inheritance >>
1026
1027 This returns a blacklist of options that can not be overridden in a
10381028 subclass's attribute definition.
10391029
10401030 This exists to allow a custom metaclass to change or add to the list
1041 of options which can be changed.
1031 of options which can not be changed.
10421032
10431033 =item B<< $attr->type_constraint >>
10441034
44
55 use Class::MOP;
66
7 our $VERSION = '1.08';
7 our $VERSION = '1.09';
88 $VERSION = eval $VERSION;
99 our $AUTHORITY = 'cpan:STEVAN';
1010
1111 use List::MoreUtils qw( any all uniq first_index );
1212 use Scalar::Util 'weaken', 'blessed';
1313
14 our $VERSION = '1.08';
14 our $VERSION = '1.09';
1515 $VERSION = eval $VERSION;
1616 our $AUTHORITY = 'cpan:STEVAN';
1717
33 use strict;
44 use warnings;
55
6 our $VERSION = '1.08';
6 our $VERSION = '1.09';
77 $VERSION = eval $VERSION;
88 our $AUTHORITY = 'cpan:STEVAN';
99
33 use strict;
44 use warnings;
55
6 our $VERSION = '1.08';
6 our $VERSION = '1.09';
77 $VERSION = eval $VERSION;
88 our $AUTHORITY = 'cpan:STEVAN';
99
110110 return $attr->should_coerce;
111111 }
112112
113 sub _generate_reader_method { shift->_generate_reader_method_inline(@_) }
114 sub _generate_writer_method { shift->_generate_writer_method_inline(@_) }
115 sub _generate_accessor_method { shift->_generate_accessor_method_inline(@_) }
116 sub _generate_predicate_method { shift->_generate_predicate_method_inline(@_) }
117 sub _generate_clearer_method { shift->_generate_clearer_method_inline(@_) }
113 sub _instance_is_inlinable {
114 my $self = shift;
115 return $self->associated_attribute->associated_class->instance_metaclass->is_inlinable;
116 }
117
118 sub _generate_reader_method {
119 my $self = shift;
120 $self->_instance_is_inlinable ? $self->_generate_reader_method_inline(@_)
121 : $self->SUPER::_generate_reader_method(@_);
122 }
123
124 sub _generate_writer_method {
125 my $self = shift;
126 $self->_instance_is_inlinable ? $self->_generate_writer_method_inline(@_)
127 : $self->SUPER::_generate_writer_method(@_);
128 }
129
130 sub _generate_accessor_method {
131 my $self = shift;
132 $self->_instance_is_inlinable ? $self->_generate_accessor_method_inline(@_)
133 : $self->SUPER::_generate_accessor_method(@_);
134 }
135
136 sub _generate_predicate_method {
137 my $self = shift;
138 $self->_instance_is_inlinable ? $self->_generate_predicate_method_inline(@_)
139 : $self->SUPER::_generate_predicate_method(@_);
140 }
141
142 sub _generate_clearer_method {
143 my $self = shift;
144 $self->_instance_is_inlinable ? $self->_generate_clearer_method_inline(@_)
145 : $self->SUPER::_generate_clearer_method(@_);
146 }
118147
119148 sub _inline_pre_body { '' }
120149 sub _inline_post_body { '' }
136165
137166 my $attr = $self->associated_attribute;
138167
139 return '' unless $attr->should_coerce;
168 return '' unless $attr->should_coerce && $attr->type_constraint->has_coercion;
140169 return "$value = \$attr->type_constraint->coerce($value);";
141170 }
142171
22 use strict;
33 use warnings;
44
5 our $VERSION = '1.08';
5 our $VERSION = '1.09';
66 $VERSION = eval $VERSION;
77 our $AUTHORITY = 'cpan:STEVAN';
88
55
66 use Scalar::Util 'blessed', 'weaken', 'looks_like_number', 'refaddr';
77
8 our $VERSION = '1.08';
8 our $VERSION = '1.09';
99 our $AUTHORITY = 'cpan:STEVAN';
1010
1111 use base 'Moose::Meta::Method',
66 use Carp 'confess';
77 use Scalar::Util 'blessed', 'weaken';
88
9 our $VERSION = '1.08';
9 our $VERSION = '1.09';
1010 $VERSION = eval $VERSION;
1111 our $AUTHORITY = 'cpan:STEVAN';
1212
77 use Scalar::Util 'blessed', 'weaken';
88 use Try::Tiny ();
99
10 our $VERSION = '1.08';
10 our $VERSION = '1.09';
1111 $VERSION = eval $VERSION;
1212 our $AUTHORITY = 'cpan:STEVAN';
1313
22 use strict;
33 use warnings;
44
5 our $VERSION = '1.08';
5 our $VERSION = '1.09';
66 $VERSION = eval $VERSION;
77 our $AUTHORITY = 'cpan:STEVAN';
88
22 use strict;
33 use warnings;
44
5 our $VERSION = '1.08';
5 our $VERSION = '1.09';
66 $VERSION = eval $VERSION;
77 our $AUTHORITY = 'cpan:STEVAN';
88
22 use strict;
33 use warnings;
44
5 our $VERSION = '1.08';
5 our $VERSION = '1.09';
66 our $AUTHORITY = 'cpan:STEVAN';
77
88 use base 'Class::MOP::Mixin::AttributeCore';
77
88 use Moose::Meta::Role::Composite;
99
10 our $VERSION = '1.08';
10 our $VERSION = '1.09';
1111 $VERSION = eval $VERSION;
1212 our $AUTHORITY = 'cpan:STEVAN';
1313
66 use Moose::Util 'english_list';
77 use Scalar::Util 'weaken', 'blessed';
88
9 our $VERSION = '1.08';
9 our $VERSION = '1.09';
1010 $VERSION = eval $VERSION;
1111 our $AUTHORITY = 'cpan:STEVAN';
1212
55
66 use Scalar::Util 'blessed';
77
8 our $VERSION = '1.08';
8 our $VERSION = '1.09';
99 $VERSION = eval $VERSION;
1010 our $AUTHORITY = 'cpan:STEVAN';
1111
55
66 use Scalar::Util 'blessed';
77
8 our $VERSION = '1.08';
8 our $VERSION = '1.09';
99 $VERSION = eval $VERSION;
1010 our $AUTHORITY = 'cpan:STEVAN';
1111
33 use warnings;
44 use metaclass;
55
6 our $VERSION = '1.08';
6 our $VERSION = '1.09';
77 $VERSION = eval $VERSION;
88 our $AUTHORITY = 'cpan:STEVAN';
99
66 use List::MoreUtils 'all';
77 use Scalar::Util 'blessed', 'weaken';
88
9 our $VERSION = '1.08';
9 our $VERSION = '1.09';
1010 our $AUTHORITY = 'cpan:STEVAN';
1111
1212 use base 'Moose::Meta::Mixin::AttributeCore';
55
66 use Scalar::Util 'blessed';
77
8 our $VERSION = '1.08';
8 our $VERSION = '1.09';
99 $VERSION = eval $VERSION;
1010 our $AUTHORITY = 'cpan:STEVAN';
1111
77
88 use base qw(Moose::Meta::Role::Method::Required);
99
10 our $VERSION = '1.08';
10 our $VERSION = '1.09';
1111 $VERSION = eval $VERSION;
1212 our $AUTHORITY = 'cpan:STEVAN';
1313
99
1010 use base qw(Class::MOP::Object);
1111
12 our $VERSION = '1.08';
12 our $VERSION = '1.09';
1313 $VERSION = eval $VERSION;
1414 our $AUTHORITY = 'cpan:STEVAN';
1515
33 use strict;
44 use warnings;
55
6 our $VERSION = '1.08';
6 our $VERSION = '1.09';
77 $VERSION = eval $VERSION;
88 our $AUTHORITY = 'cpan:STEVAN';
99
88 use Carp 'confess';
99 use Devel::GlobalDestruction 'in_global_destruction';
1010
11 our $VERSION = '1.08';
11 our $VERSION = '1.09';
1212 $VERSION = eval $VERSION;
1313 our $AUTHORITY = 'cpan:STEVAN';
1414
389389 }
390390
391391 sub find_method_by_name { (shift)->get_method(@_) }
392
393 sub alias_method {
394 Carp::cluck("The alias_method method is deprecated. Use add_method instead.\n");
395
396 my $self = shift;
397
398 $self->add_method(@_);
399 }
400392
401393 ## ------------------------------------------------------------------
402394 ## role construction
66
77 use Scalar::Util 'blessed';
88
9 our $VERSION = '1.08';
9 our $VERSION = '1.09';
1010 $VERSION = eval $VERSION;
1111 our $AUTHORITY = 'cpan:STEVAN';
1212
77 use Moose::Meta::Attribute;
88 use Moose::Util::TypeConstraints ();
99
10 our $VERSION = '1.08';
10 our $VERSION = '1.09';
1111 $VERSION = eval $VERSION;
1212 our $AUTHORITY = 'cpan:STEVAN';
1313
66 use Scalar::Util 'blessed';
77 use Moose::Util::TypeConstraints ();
88
9 our $VERSION = '1.08';
9 our $VERSION = '1.09';
1010 $VERSION = eval $VERSION;
1111 our $AUTHORITY = 'cpan:STEVAN';
1212
99
1010 use Moose::Util::TypeConstraints ();
1111
12 our $VERSION = '1.08';
12 our $VERSION = '1.09';
1313 $VERSION = eval $VERSION;
1414 our $AUTHORITY = 'cpan:STEVAN';
1515
55
66 use Moose::Util::TypeConstraints ();
77
8 our $VERSION = '1.08';
8 our $VERSION = '1.09';
99 $VERSION = eval $VERSION;
1010 our $AUTHORITY = 'cpan:STEVAN';
1111
33 use warnings;
44 use metaclass;
55
6 our $VERSION = '1.08';
6 our $VERSION = '1.09';
77 $VERSION = eval $VERSION;
88 our $AUTHORITY = 'cpan:STEVAN';
99
77 use Moose::Util::TypeConstraints;
88 use Moose::Meta::TypeConstraint::Parameterizable;
99
10 our $VERSION = '1.08';
10 our $VERSION = '1.09';
1111 $VERSION = eval $VERSION;
1212 our $AUTHORITY = 'cpan:STEVAN';
1313
66
77 use Scalar::Util 'blessed';
88
9 our $VERSION = '1.08';
9 our $VERSION = '1.09';
1010 $VERSION = eval $VERSION;
1111 our $AUTHORITY = 'cpan:STEVAN';
1212
66 use Scalar::Util 'blessed';
77 use Moose::Util::TypeConstraints ();
88
9 our $VERSION = '1.08';
9 our $VERSION = '1.09';
1010 $VERSION = eval $VERSION;
1111 our $AUTHORITY = 'cpan:STEVAN';
1212
88
99 use List::Util qw(first);
1010
11 our $VERSION = '1.08';
11 our $VERSION = '1.09';
1212 $VERSION = eval $VERSION;
1313 our $AUTHORITY = 'cpan:STEVAN';
1414
1414
1515 use base qw(Class::MOP::Object);
1616
17 our $VERSION = '1.08';
17 our $VERSION = '1.09';
1818 $VERSION = eval $VERSION;
1919 our $AUTHORITY = 'cpan:STEVAN';
2020
1111 use if ( not our $__mx_is_compiled ), 'Moose::Meta::Class';
1212 use if ( not our $__mx_is_compiled ), metaclass => 'Moose::Meta::Class';
1313
14 our $VERSION = '1.08';
14 our $VERSION = '1.09';
1515 $VERSION = eval $VERSION;
1616 our $AUTHORITY = 'cpan:STEVAN';
1717
66
77 use Sub::Exporter;
88
9 our $VERSION = '1.08';
9 our $VERSION = '1.09';
1010 $VERSION = eval $VERSION;
1111 our $AUTHORITY = 'cpan:STEVAN';
1212
33 use warnings;
44 use Scalar::Util 'blessed';
55
6 our $VERSION = '1.08';
6 our $VERSION = '1.09';
77 $VERSION = eval $VERSION;
88 our $AUTHORITY = 'cpan:STEVAN';
99
1010 use List::MoreUtils qw( all );
1111 use List::Util qw( first );
12 use Moose::Deprecated;
1213
1314 sub apply_metaclass_roles {
15 Moose::Deprecated::deprecated(
16 feature => 'pre-0.94 MetaRole API',
17 message =>
18 'The old Moose::Util::MetaRole API (before version 0.94) has been deprecated'
19 );
20
1421 goto &apply_metaroles;
1522 }
1623
3542 sub _fixup_old_style_args {
3643 my $args = shift;
3744
38 return if $args->{class_metaroles} || $args->{roles_metaroles};
45 return if $args->{class_metaroles} || $args->{role_metaroles};
46
47 Moose::Deprecated::deprecated(
48 feature => 'pre-0.94 MetaRole API',
49 message =>
50 'The old Moose::Util::MetaRole API (before version 0.94) has been deprecated'
51 );
3952
4053 $args->{for} = delete $args->{for_class}
4154 if exists $args->{for_class};
33 use warnings;
44
55 use Class::MOP;
6 use Moose::Deprecated;
67 use Scalar::Util 'blessed', 'looks_like_number';
78
8 our $VERSION = '1.08';
9 our $VERSION = '1.09';
910 $VERSION = eval $VERSION;
1011 our $AUTHORITY = 'cpan:STEVAN';
1112
3536
3637 sub Object { blessed($_[0]) && blessed($_[0]) ne 'Regexp' }
3738
38 sub Role { Carp::cluck('The Role type is deprecated.'); blessed($_[0]) && $_[0]->can('does') }
39 sub Role {
40 Moose::Deprecated::deprecated(
41 feature => 'Role type',
42 message =>
43 'The Role type has been deprecated. Maybe you meant to create a RoleName type?'
44 );
45 blessed( $_[0] ) && $_[0]->can('does');
46 }
3947
4048 sub ClassName {
4149 return Class::MOP::is_class_loaded( $_[0] );
55 use Scalar::Util qw( blessed reftype );
66 use Moose::Exporter;
77
8 our $VERSION = '1.08';
8 our $VERSION = '1.09';
99 $VERSION = eval $VERSION;
1010 our $AUTHORITY = 'cpan:STEVAN';
1111
2424
2525 ## --------------------------------------------------------
2626
27 use Moose::Deprecated;
2728 use Moose::Meta::TypeConstraint;
2829 use Moose::Meta::TypeConstraint::Union;
2930 use Moose::Meta::TypeConstraint::Parameterized;
274275
275276 # back-compat version, called without sugar
276277 if ( !any { ( reftype($_) || '' ) eq 'HASH' } @_ ) {
278 Moose::Deprecated::deprecated(
279 feature => 'type without sugar',
280 message =>
281 'Calling type() with a simple list of parameters is deprecated'
282 );
283
277284 return _create_type_constraint( $_[0], undef, $_[1] );
278285 }
279286
293300 #
294301 # subtype 'Parent', sub { where };
295302 if ( scalar @_ == 2 && ( reftype( $_[1] ) || '' ) eq 'CODE' ) {
303 Moose::Deprecated::deprecated(
304 feature => 'subtype without sugar',
305 message =>
306 'Calling subtype() with a simple list of parameters is deprecated'
307 );
308
296309 return _create_type_constraint( undef, @_ );
297310 }
298311
300313 # subtype 'Parent', sub { where }, sub { message }, sub { optimized };
301314 if ( scalar @_ >= 3 && all { ( reftype($_) || '' ) eq 'CODE' }
302315 @_[ 1 .. $#_ ] ) {
316 Moose::Deprecated::deprecated(
317 feature => 'subtype without sugar',
318 message =>
319 'Calling subtype() with a simple list of parameters is deprecated'
320 );
321
303322 return _create_type_constraint( undef, @_ );
304323 }
305324
306325 # subtype 'Name', 'Parent', ...
307326 if ( scalar @_ >= 2 && all { !ref } @_[ 0, 1 ] ) {
327 Moose::Deprecated::deprecated(
328 feature => 'subtype without sugar',
329 message =>
330 'Calling subtype() with a simple list of parameters is deprecated'
331 );
332
308333 return _create_type_constraint(@_);
309334 }
310335
572597
573598 my $valid_chars = qr{[\w:\.]};
574599 my $type_atom = qr{ (?>$valid_chars+) }x;
575 my $ws = qr{ (?>\s*) }x;
576
577 my $any;
578
579 my $type = qr{ $type_atom (?: \[ $ws (??{$any}) $ws \] )? }x;
580 my $type_capture_parts
581 = qr{ ($type_atom) (?: \[ $ws ((??{$any})) $ws \] )? }x;
582 my $type_with_parameter
583 = qr{ $type_atom \[ $ws (??{$any}) $ws \] }x;
584
585 my $op_union = qr{ $ws \| $ws }x;
586 my $union = qr{ $type (?> (?: $op_union $type )+ ) }x;
587
588 $any = qr{ $type | $union }x;
600 my $ws = qr{ (?>\s*) }x;
601 my $op_union = qr{ $ws \| $ws }x;
602
603 my ($type, $type_capture_parts, $type_with_parameter, $union, $any);
604 if (Class::MOP::IS_RUNNING_ON_5_10) {
605 my $type_pattern
606 = q{ (?&type_atom) (?: \[ (?&ws) (?&any) (?&ws) \] )? };
607 my $type_capture_parts_pattern
608 = q{ ((?&type_atom)) (?: \[ (?&ws) ((?&any)) (?&ws) \] )? };
609 my $type_with_parameter_pattern
610 = q{ (?&type_atom) \[ (?&ws) (?&any) (?&ws) \] };
611 my $union_pattern
612 = q{ (?&type) (?> (?: (?&op_union) (?&type) )+ ) };
613 my $any_pattern
614 = q{ (?&type) | (?&union) };
615
616 my $defines = qr{(?(DEFINE)
617 (?<valid_chars> $valid_chars)
618 (?<type_atom> $type_atom)
619 (?<ws> $ws)
620 (?<op_union> $op_union)
621 (?<type> $type_pattern)
622 (?<type_capture_parts> $type_capture_parts_pattern)
623 (?<type_with_parameter> $type_with_parameter_pattern)
624 (?<union> $union_pattern)
625 (?<any> $any_pattern)
626 )}x;
627
628 $type = qr{ $type_pattern $defines }x;
629 $type_capture_parts = qr{ $type_capture_parts_pattern $defines }x;
630 $type_with_parameter = qr{ $type_with_parameter_pattern $defines }x;
631 $union = qr{ $union_pattern $defines }x;
632 $any = qr{ $any_pattern $defines }x;
633 }
634 else {
635 $type
636 = qr{ $type_atom (?: \[ $ws (??{$any}) $ws \] )? }x;
637 $type_capture_parts
638 = qr{ ($type_atom) (?: \[ $ws ((??{$any})) $ws \] )? }x;
639 $type_with_parameter
640 = qr{ $type_atom \[ $ws (??{$any}) $ws \] }x;
641 $union
642 = qr{ $type (?> (?: $op_union $type )+ ) }x;
643 $any
644 = qr{ $type | $union }x;
645 }
646
589647
590648 sub _parse_parameterized_type_constraint {
591649 { no warnings 'void'; $any; } # force capture of interpolated lexical
77 use Scalar::Util 'blessed';
88 use Class::MOP 0.60;
99
10 our $VERSION = '1.08';
10 our $VERSION = '1.09';
1111 $VERSION = eval $VERSION;
1212 our $AUTHORITY = 'cpan:STEVAN';
1313
1717 search_class_by_role
1818 ensure_all_roles
1919 apply_all_roles
20 with_traits
2021 get_all_init_args
2122 get_all_attribute_values
2223 resolve_metatrait_alias
133134 else {
134135 Moose::Meta::Role->combine(@role_metas)->apply($meta);
135136 }
137 }
138
139 sub with_traits {
140 my ($class, @roles) = @_;
141 return $class unless @roles;
142 return Moose::Meta::Class->create_anon_class(
143 superclasses => [$class],
144 roles => \@roles,
145 cache => 1,
146 )->name;
136147 }
137148
138149 # instance deconstruction ...
344355 This function is similar to L</apply_all_roles>, but only applies roles that
345356 C<$applicant> does not already consume.
346357
358 =item B<with_traits($class_name, @role_names)>
359
360 This function creates a new class from C<$class_name> with each of
361 C<@role_names> applied. It returns the name of the new class.
362
347363 =item B<get_all_attribute_values($meta, $instance)>
348364
349365 Returns a hash reference containing all of the C<$instance>'s
33
44 use 5.008;
55
6 our $VERSION = '1.08';
6 our $VERSION = '1.09';
77 $VERSION = eval $VERSION;
88 our $AUTHORITY = 'cpan:STEVAN';
99
1010 use Scalar::Util 'blessed';
1111 use Carp 'confess';
1212
13 use Moose::Deprecated;
1314 use Moose::Exporter;
1415
1516 use Class::MOP 0.94;
132133 # This used to be called as a function. This hack preserves
133134 # backwards compatibility.
134135 if ( $_[0] ne __PACKAGE__ ) {
136 Moose::Deprecated::deprecated(
137 feature => 'Moose::init_meta',
138 message => 'Calling Moose::init_meta as a function is deprecated',
139 );
140
135141 return __PACKAGE__->init_meta(
136142 for_class => $_[0],
137143 base_class => $_[1],
974980
975981 An alias for C<confess>, used by internally by Moose.
976982
977 =head1 METACLASS COMPATIBILITY AND MOOSE
978
979 Metaclass compatibility is a thorny subject. You should start by
980 reading the "About Metaclass compatibility" section in the
981 C<Class::MOP> docs.
982
983 Moose will attempt to resolve a few cases of metaclass incompatibility
984 when you set the superclasses for a class, in addition to the cases that
985 C<Class::MOP> handles.
986
987 Moose tries to determine if the metaclasses only "differ by roles". This
988 means that the parent and child's metaclass share a common ancestor in
989 their respective hierarchies, and that the subclasses under the common
990 ancestor are only different because of role applications. This case is
991 actually fairly common when you mix and match various C<MooseX::*>
992 modules, many of which apply roles to the metaclass.
993
994 If the parent and child do differ by roles, Moose replaces the
995 metaclass in the child with a newly created metaclass. This metaclass
996 is a subclass of the parent's metaclass, does all of the roles that
997 the child's metaclass did before being replaced. Effectively, this
998 means the new metaclass does all of the roles done by both the
999 parent's and child's original metaclasses.
1000
1001 Ultimately, this is all transparent to you except in the case of an
1002 unresolvable conflict.
1003
1004983 =head2 The MooseX:: namespace
1005984
1006985 Generally if you're writing an extension I<for> Moose itself you'll want
1011990 and C<DBIx::> namespaces that perform the same function for C<LWP> and C<DBI>
1012991 respectively.
1013992
993 =head1 METACLASS COMPATIBILITY AND MOOSE
994
995 Metaclass compatibility is a thorny subject. You should start by
996 reading the "About Metaclass compatibility" section in the
997 C<Class::MOP> docs.
998
999 Moose will attempt to resolve a few cases of metaclass incompatibility
1000 when you set the superclasses for a class, in addition to the cases that
1001 C<Class::MOP> handles.
1002
1003 Moose tries to determine if the metaclasses only "differ by roles". This
1004 means that the parent and child's metaclass share a common ancestor in
1005 their respective hierarchies, and that the subclasses under the common
1006 ancestor are only different because of role applications. This case is
1007 actually fairly common when you mix and match various C<MooseX::*>
1008 modules, many of which apply roles to the metaclass.
1009
1010 If the parent and child do differ by roles, Moose replaces the
1011 metaclass in the child with a newly created metaclass. This metaclass
1012 is a subclass of the parent's metaclass, does all of the roles that
1013 the child's metaclass did before being replaced. Effectively, this
1014 means the new metaclass does all of the roles done by both the
1015 parent's and child's original metaclasses.
1016
1017 Ultimately, this is all transparent to you except in the case of an
1018 unresolvable conflict.
1019
10141020 =head1 CAVEATS
10151021
10161022 =over 4
88 use List::MoreUtils 'all';
99 use Moose::Util 'does_role', 'find_meta';
1010
11 our $VERSION = '1.08';
11 our $VERSION = '1.09';
1212 $VERSION = eval $VERSION;
1313 our $AUTHORITY = 'cpan:STEVAN';
1414
44
55 use Class::MOP;
66
7 our $VERSION = '1.08';
7 our $VERSION = '1.09';
88 $VERSION = eval $VERSION;
99 our $AUTHORITY = 'cpan:STEVAN';
1010
2121 ::ok($warn, '... got a warning');
2222 ::like($warn, qr/Argument \"hello\" isn\'t numeric in addition \(\+\)/, '.. and it is the right warning');
2323 }
24
25 no Moose;
26 undef $@;
27 eval '$foo = 5;';
28 ::ok(!$@, "... no error after no Moose");
29
30 {
31 my $warn;
32 local $SIG{__WARN__} = sub { $warn = $_[0] };
33
34 ::ok(!$warn, '... no warning yet');
35
36 eval 'my $bar = 1 + "hello"';
37
38 ::ok(!$warn, '... still no warning');
39 }
4024 }
4125
4226 # and for roles ...
5943 ::ok($warn, '... got a warning');
6044 ::like($warn, qr/Argument \"hello\" isn\'t numeric in addition \(\+\)/, '.. and it is the right warning');
6145 }
62
63 no Moose::Role;
64 undef $@;
65 eval '$foo = 5;';
66 ::ok(!$@, "... no error after no Moose::Role");
67
68 {
69 my $warn;
70 local $SIG{__WARN__} = sub { $warn = $_[0] };
71
72 ::ok(!$warn, '... no warning yet');
73
74 eval 'my $bar = 1 + "hello"';
75
76 ::ok(!$warn, '... still no warning');
77 }
7846 }
7947
8048 # and for exporters
8250 package Bar;
8351 use Moose::Exporter;
8452
85 eval '$foo2 = 5;';
53 eval '$foo = 5;';
8654 ::ok($@, '... got an error because strict is on');
87 ::like($@, qr/Global symbol \"\$foo2\" requires explicit package name at/, '... got the right error');
55 ::like($@, qr/Global symbol \"\$foo\" requires explicit package name at/, '... got the right error');
8856
8957 {
9058 my $warn;
9765 ::ok($warn, '... got a warning');
9866 ::like($warn, qr/Argument \"hello\" isn\'t numeric in addition \(\+\)/, '.. and it is the right warning');
9967 }
100
101 no Moose::Exporter;
102 undef $@;
103 eval '$foo = 5;';
104 ::ok(!$@, "... no error after no Moose::Exporter");
105
106 {
107 my $warn;
108 local $SIG{__WARN__} = sub { $warn = $_[0] };
109
110 ::ok(!$warn, '... no warning yet');
111
112 eval 'my $bar = 1 + "hello"';
113
114 ::ok(!$warn, '... still no warning');
115 }
11668 }
11769
11870 done_testing;
77
88
99 {
10 package Thing::Meta::Attribute;
11 use Moose;
12
13 extends 'Moose::Meta::Attribute';
14 around illegal_options_for_inheritance => sub {
15 return (shift->(@_), qw/trigger/);
16 };
17
1018 package Thing;
1119 use Moose;
1220
4250
4351 # this one will work here ....
4452 has 'fail' => (isa => 'CodeRef', is => 'bare');
45 has 'other_fail' => (is => 'bare');
53 has 'other_fail' => (metaclass => 'Thing::Meta::Attribute', is => 'bare', trigger => sub { });
4654
4755 package Bar;
4856 use Moose;
0 #!/usr/bin/perl
1
2 use strict;
3 use warnings;
4 use Test::More;
5 use Test::Exception;
6
7 {
8 package Foo;
9 use Moose;
10
11 has foo => (
12 is => 'ro',
13 );
14
15 has bar => (
16 clearer => 'clear_bar',
17 );
18 }
19
20 {
21 package Foo::Sub;
22 use Moose;
23
24 extends 'Foo';
25
26 ::throws_ok { has '+foo' => (is => 'rw') } qr/illegal/, "can't override is";
27 ::throws_ok { has '+foo' => (reader => 'bar') } qr/illegal/, "can't override reader";
28 ::lives_ok { has '+foo' => (clearer => 'baz') } "can override unspecified things";
29
30 ::throws_ok { has '+bar' => (clearer => 'quux') } qr/illegal/, "can't override clearer";
31 ::lives_ok { has '+bar' => (predicate => 'has_bar') } "can override unspecified things";
32 }
33
34 {
35 package Bar::Meta::Attribute;
36 use Moose::Role;
37
38 has my_illegal_option => (is => 'ro');
39
40 around illegal_options_for_inheritance => sub {
41 return (shift->(@_), 'my_illegal_option');
42 };
43 }
44
45 {
46 package Bar;
47 use Moose;
48
49 ::lives_ok {
50 has bar => (
51 traits => ['Bar::Meta::Attribute'],
52 my_illegal_option => 'FOO',
53 is => 'bare',
54 );
55 } "can use illegal options";
56
57 has baz => (
58 traits => ['Bar::Meta::Attribute'],
59 is => 'bare',
60 );
61 }
62
63 {
64 package Bar::Sub;
65 use Moose;
66
67 extends 'Bar';
68
69 ::throws_ok { has '+bar' => (my_illegal_option => 'BAR') }
70 qr/illegal/,
71 "can't override illegal attribute";
72 ::lives_ok { has '+baz' => (my_illegal_option => 'BAR') }
73 "can add illegal option if superclass doesn't set it";
74 }
75
76 my $bar_attr = Bar->meta->get_attribute('bar');
77 ok((grep { $_ eq 'my_illegal_option' } $bar_attr->illegal_options_for_inheritance) > 0, '... added my_illegal_option as illegal option for inheritance');
78
79 done_testing;
+0
-50
t/020_attributes/022_legal_options_for_inheritance.t less more
0 #!/usr/bin/perl
1
2 use strict;
3 use warnings;
4 use Test::More;
5
6
7 {
8 package Bar::Meta::Attribute;
9 use Moose;
10
11 extends 'Moose::Meta::Attribute';
12
13 has 'my_legal_option' => (
14 isa => 'CodeRef',
15 is => 'rw',
16 );
17
18 around legal_options_for_inheritance => sub {
19 return (shift->(@_), qw/my_legal_option/);
20 };
21
22 package Bar;
23 use Moose;
24
25 has 'bar' => (
26 metaclass => 'Bar::Meta::Attribute',
27 my_legal_option => sub { 'Bar' },
28 is => 'bare',
29 );
30
31 package Bar::B;
32 use Moose;
33
34 extends 'Bar';
35
36 has '+bar' => (
37 my_legal_option => sub { 'Bar::B' }
38 );
39 }
40
41 my $bar_attr = Bar::B->meta->get_attribute('bar');
42 my ($legal_option) = grep {
43 $_ eq 'my_legal_option'
44 } $bar_attr->legal_options_for_inheritance;
45 is($legal_option, 'my_legal_option',
46 '... added my_legal_option as legal option for inheritance' );
47 is($bar_attr->my_legal_option->(), 'Bar::B', '... overloaded my_legal_option');
48
49 done_testing;
3030 stderr_like(sub { $foo_meta->add_attribute(e => (is => 'rw')) },
3131 qr/^You are overwriting a locally defined method \(e\) with an accessor/, 'accessor overriding gives proper warning');
3232
33 stderr_like(sub { $foo_meta->add_attribute(has => (is => 'rw')) },
34 qr/^You are overwriting a locally defined function \(has\) with an accessor/, 'function overriding gives proper warning');
35
3336 done_testing;
0 #!/usr/bin/env perl
1 use strict;
2 use warnings;
3 use Test::More;
4
5 my $called;
6 {
7 package Foo::Meta::Instance;
8 use Moose::Role;
9
10 sub is_inlinable { 0 }
11
12 after get_slot_value => sub { $called++ };
13 }
14
15 {
16 package Foo;
17 use Moose;
18 Moose::Util::MetaRole::apply_metaroles(
19 for => __PACKAGE__,
20 class_metaroles => {
21 instance => ['Foo::Meta::Instance'],
22 },
23 );
24
25 has foo => (is => 'ro');
26 }
27
28 my $foo = Foo->new(foo => 1);
29 is($foo->foo, 1, "got the right value");
30 is($called, 1, "reader was called");
31
32 done_testing;
0 use strict;
1 use warnings;
2
3 use Test::More;
4 BEGIN {
5 eval "use Test::Output;";
6 plan skip_all => "Test::Output is required for this test" if $@;
7 }
8
9 {
10 package Foo;
11
12 use Moose;
13
14 ::stderr_like{ has foo => (
15 is => 'ro',
16 isa => 'Str',
17 coerce => 1,
18 );
19 }
20 qr/\QYou cannot coerce an attribute (foo) unless its type (Str) has a coercion/,
21 'Cannot coerce unless the type has a coercion';
22
23 ::stderr_like{ has bar => (
24 is => 'ro',
25 isa => 'Str',
26 coerce => 1,
27 );
28 }
29 qr/\QYou cannot coerce an attribute (bar) unless its type (Str) has a coercion/,
30 'Cannot coerce unless the type has a coercion - different attribute';
31 }
32
33 done_testing;
193193 # sugar was indistinguishable from calling directly.
194194
195195 {
196 no warnings 'redefine';
197 *Moose::Deprecated::deprecated = sub { return };
198 }
199
200 {
196201 my $type = type( 'Number2', sub { Scalar::Util::looks_like_number($_) } );
197202
198203 ok( $type->check(5), '... this is a Num' );
1717
1818 package MyFramework;
1919 use Moose;
20 use Moose::Deprecated -api_version => '0.55';
2021
2122 sub import {
2223 my $CALLER = caller();
110110 use Moose ();
111111
112112 sub wrapped2 {
113 my $caller = shift;
113 my $caller = shift->name;
114114 return $caller . ' called wrapped2';
115115 }
116116
119119 }
120120
121121 Moose::Exporter->setup_import_methods(
122 with_caller => ['wrapped2'],
123 as_is => ['as_is1'],
124 also => 'MooseX::Sugar',
122 with_meta => ['wrapped2'],
123 as_is => ['as_is1'],
124 also => 'MooseX::Sugar',
125125 );
126126 }
127127
261261 use Moose ();
262262
263263 sub has {
264 my $caller = shift;
264 my $caller = shift->name;
265265 return $caller . ' called has';
266266 }
267267
268268 Moose::Exporter->setup_import_methods(
269 with_caller => ['has'],
270 also => 'Moose',
269 with_meta => ['has'],
270 also => 'Moose',
271271 );
272272 }
273273
297297 ::stderr_like {
298298 Moose::Exporter->setup_import_methods(
299299 also => ['Moose'],
300 with_caller => ['does_not_exist'],
300 with_meta => ['does_not_exist'],
301301 );
302302 } qr/^Trying to export undefined sub NonExistentExport::does_not_exist/,
303303 "warns when a non-existent method is requested to be exported";
315315 {
316316 package AllOptions;
317317 use Moose ();
318 use Moose::Deprecated -api_version => '0.88';
318319 use Moose::Exporter;
319320
320321 Moose::Exporter->setup_import_methods(
571571 my %p = @_;
572572 Moose->init_meta(%p);
573573 return Moose::Util::MetaRole::apply_metaroles(
574 for_class => $p{for_class},
574 for => $p{for_class},
575575 # Causes us to recurse through init_meta, as we have to
576576 # load MyMetaclassRole from disk.
577 metaclass_roles => [qw/MyMetaclassRole/],
577 class_metaroles => { class => [qw/MyMetaclassRole/] },
578578 );
579579 }
580580 }
2525 use Moose::Exporter;
2626
2727 Moose::Exporter->setup_import_methods(
28 metaclass_roles => ['Foo::Trait::Class'],
29 role_metaclass_roles => ['Foo::Trait::Class'],
30 attribute_metaclass_roles => ['Foo::Trait::Attribute'],
31 base_class_roles => ['Foo::Role::Base'],
28 class_metaroles => {
29 class => ['Foo::Trait::Class'],
30 attribute => ['Foo::Trait::Attribute'],
31 },
32 role_metaroles => { role => ['Foo::Trait::Class'] },
33 base_class_roles => ['Foo::Role::Base'],
3234 );
3335 }
3436
4951 use Moose ();
5052 use Moose::Exporter;
5153
52 my ($import, $unimport, $init_meta) =
53 Moose::Exporter->build_import_methods(
54 also => 'Moose',
55 metaclass_roles => ['Foo::Trait::Class'],
56 attribute_metaclass_roles => ['Foo::Trait::Attribute'],
57 base_class_roles => ['Foo::Role::Base'],
58 install => [qw(import unimport)],
54 my ( $import, $unimport, $init_meta )
55 = Moose::Exporter->build_import_methods(
56 also => 'Moose',
57 class_metaroles => {
58 class => ['Foo::Trait::Class'],
59 attribute => ['Foo::Trait::Attribute'],
60 },
61 base_class_roles => ['Foo::Role::Base'],
62 install => [qw(import unimport)],
5963 );
6064
6165 sub init_meta {
113113 sub init_meta {
114114 my ( $self, %options ) = @_;
115115 return Moose::Util::MetaRole::apply_metaroles(
116 for_class => Moose::Role->init_meta(%options),
116 for => Moose::Role->init_meta(%options),
117117 role_metaroles => {
118118 role => ['Role::WithCustomApplication'],
119119 application_to_class =>
1212
1313 use Moose::Util::MetaRole;
1414
15 {
16 no warnings 'redefine';
17 *Moose::Deprecated::deprecated = sub { return };
18 }
1519
1620 {
1721 package My::Meta::Class;
0 use strict;
1 use warnings;
2
3 use Test::More;
4 use Test::Exception;
5 use Test::Moose;
6
7 {
8 package Foo;
9
10 use Moose::Deprecated -api_version => '1.07';
11 use Moose;
12
13 has x => (
14 is => 'rw',
15 isa => 'HashRef',
16 coerce => 1,
17 );
18 }
19
20 with_immutable {
21 lives_ok { Foo->new( x => {} ) }
22 'Setting coerce => 1 without a coercion on the type does not cause an error in the constructor';
23
24 lives_ok { Foo->new->x( {} ) }
25 'Setting coerce => 1 without a coercion on the type does not cause an error when setting the attribut';
26
27 throws_ok { Foo->new( x => 42 ) }
28 qr/\QAttribute (x) does not pass the type constraint because/,
29 'Attempting to provide an invalid value to the constructor for this attr still fails';
30
31 throws_ok { Foo->new->x(42) }
32 qr/\QAttribute (x) does not pass the type constraint because/,
33 'Attempting to provide an invalid value to the accessor for this attr still fails';
34 }
35 'Foo';
36
37 done_testing;
0 #!/usr/bin/env perl
1 use strict;
2 use warnings;
3 use Test::More;
4 use Test::Moose;
5
6 use Moose ();
7 use Moose::Util qw(with_traits);
8
9 {
10 package Foo;
11 use Moose;
12 }
13
14 {
15 package Foo::Role;
16 use Moose::Role;
17 }
18
19 {
20 package Foo::Role2;
21 use Moose::Role;
22 }
23
24 {
25 my $traited_class = with_traits('Foo', 'Foo::Role');
26 ok($traited_class->meta->is_anon_class, "we get an anon class");
27 isa_ok($traited_class, 'Foo');
28 does_ok($traited_class, 'Foo::Role');
29 }
30
31 {
32 my $traited_class = with_traits('Foo', 'Foo::Role', 'Foo::Role2');
33 ok($traited_class->meta->is_anon_class, "we get an anon class");
34 isa_ok($traited_class, 'Foo');
35 does_ok($traited_class, 'Foo::Role');
36 does_ok($traited_class, 'Foo::Role2');
37 }
38
39 {
40 my $traited_class = with_traits('Foo');
41 is($traited_class, 'Foo', "don't apply anything if we don't get any traits");
42 }
43
44 {
45 my $traited_class = with_traits('Foo', 'Foo::Role');
46 my $traited_class2 = with_traits('Foo', 'Foo::Role');
47 is($traited_class, $traited_class2, "get the same class back when passing the same roles");
48 }
49
50 done_testing;
44 use Test::More;
55
66 Moose::Exporter->setup_import_methods(
7 with_caller => [ qw(with_prototype) ],
8 as_is => [ qw(as_is_prototype) ],
7 with_meta => [qw(with_prototype)],
8 as_is => [qw(as_is_prototype)],
99 );
1010
1111 sub with_prototype (&) {
2020 $code->();
2121 }
2222
23 1;
23 1;
1313 plan tests => scalar @modules;
1414
1515 my %trustme = (
16 'Moose::Exporter' => ['unimport'],
1716 'Moose::Meta::Attribute' => [
1817 qw( interpolate_class
1918 throw_error
200200 utils
201201 whitelist
202202 Whitelist
203 whitelisted
203204 workflow
204205
205206 ## other jargon
3838 MooseX::AttributeCloner
3939 MooseX::AttributeDefaults
4040 MooseX::AttributeHelpers
41 MooseX::AttributeIndexes
4241 MooseX::AttributeInflate
4342 MooseX::Attributes::Curried
43 MooseX::AutoDestruct
4444 MooseX::Blessed::Reconstruct
45 MooseX::CascadeClearing
4645 MooseX::ClassAttribute
4746 MooseX::Clone
4847 MooseX::ConfigFromFile
5554 MooseX::DeepAccessors
5655 MooseX::Dumper
5756 MooseX::Emulate::Class::Accessor::Fast
58 MooseX::Error::Exception::Class
5957 MooseX::Error::Trap
60 MooseX::FSM
6158 MooseX::FileAttribute
6259 MooseX::File_or_DB::Storage
6360 MooseX::FollowPBP
8077 MooseX::MakeImmutable
8178 MooseX::Mangle
8279 MooseX::MarkAsMethods
83 MooseX::Meta::Attribute::Index
84 MooseX::Meta::Attribute::Lvalue
8580 MooseX::Meta::TypeConstraint::ForceCoercion
8681 MooseX::Meta::TypeConstraint::Intersection
8782 MooseX::MetaDescription
9186 MooseX::MultiInitArg
9287 MooseX::MultiMethods
9388 MooseX::MutatorAttributes
94 MooseX::Net::API
9589 MooseX::NonMoose
9690 MooseX::Object::Pluggable
9791 MooseX::Param
189183 Markdent
190184 namespace::autoclean
191185 NetHack::Item
186 Net::HTTP::API
192187 Net::Twitter
193188 Path::Router
194189 Pod::Elemental