* 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
0 | 0 | Also see Moose::Manual::Delta for more details of, and workarounds |
1 | 1 | 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. | |
2 | 54 | |
3 | 55 | 1.08 Tue, Jun 15, 2010 |
4 | 56 |
39 | 39 | lib/Moose/Cookbook/Snack/Keywords.pod |
40 | 40 | lib/Moose/Cookbook/Snack/Types.pod |
41 | 41 | lib/Moose/Cookbook/Style.pod |
42 | lib/Moose/Deprecated.pm | |
42 | 43 | lib/Moose/Error/Confess.pm |
43 | 44 | lib/Moose/Error/Croak.pm |
44 | 45 | lib/Moose/Error/Default.pm |
188 | 189 | t/020_attributes/019_attribute_lazy_initializer.t |
189 | 190 | t/020_attributes/020_trigger_and_coerce.t |
190 | 191 | 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 | |
192 | 193 | t/020_attributes/023_attribute_names.t |
193 | 194 | t/020_attributes/024_attribute_traits_parameterized.t |
194 | 195 | t/020_attributes/025_chained_coercion.t |
199 | 200 | t/020_attributes/030_non_alpha_attr_names.t |
200 | 201 | t/020_attributes/031_delegation_and_modifiers.t |
201 | 202 | t/020_attributes/032_delegation_arg_aliasing.t |
203 | t/020_attributes/033_accessor_inlining.t | |
204 | t/020_attributes/034_bad_coerce.t | |
202 | 205 | t/030_roles/001_meta_role.t |
203 | 206 | t/030_roles/002_role.t |
204 | 207 | t/030_roles/003_apply_role.t |
347 | 350 | t/100_bugs/027_constructor_object_overload.t |
348 | 351 | t/100_bugs/028_apply_role_to_one_instance_only.t |
349 | 352 | t/100_bugs/029_instance_application_role_args.t |
353 | t/100_bugs/030_coerce_without_coercion.t | |
350 | 354 | t/200_examples/001_example.t |
351 | 355 | t/200_examples/002_example_Moose_POOP.t |
352 | 356 | t/200_examples/003_example.t |
378 | 382 | t/400_moose_util/006_create_alias.t |
379 | 383 | t/400_moose_util/007_apply_roles.t |
380 | 384 | t/400_moose_util/008_method_mod_args.t |
385 | t/400_moose_util/009_with_traits.t | |
381 | 386 | t/500_test_moose/001_test_moose.t |
382 | 387 | t/500_test_moose/002_test_moose_does_ok.t |
383 | 388 | t/500_test_moose/003_test_moose_has_attribute_ok.t |
8 | 8 | configure_requires: |
9 | 9 | ExtUtils::MakeMaker: 6.42 |
10 | 10 | distribution_type: module |
11 | generated_by: 'Module::Install version 0.99' | |
11 | generated_by: 'Module::Install version 1.00' | |
12 | 12 | license: perl |
13 | 13 | meta-spec: |
14 | 14 | url: http://module-build.sourceforge.net/META-spec-v1.4.html |
21 | 21 | - xt |
22 | 22 | requires: |
23 | 23 | Carp: 0 |
24 | Class::MOP: 1.02 | |
24 | Class::MOP: 1.04 | |
25 | 25 | Data::OptList: 0 |
26 | 26 | List::MoreUtils: 0.12 |
27 | Package::DeprecationManager: 0.04 | |
27 | 28 | Scalar::Util: 1.19 |
28 | 29 | Sub::Exporter: 0.980 |
29 | 30 | Sub::Name: 0 |
30 | 31 | Task::Weaken: 0 |
31 | 32 | Try::Tiny: 0.02 |
32 | perl: 5.8.1 | |
33 | perl: 5.8.3 | |
33 | 34 | resources: |
34 | 35 | license: http://dev.perl.org/licenses/ |
35 | 36 | repository: git://git.moose.perl.org/Moose.git |
36 | version: 1.08 | |
37 | version: 1.09 | |
37 | 38 | x_authority: cpan:STEVAN |
1 | 1 | use warnings; |
2 | 2 | use inc::Module::Install 0.98; |
3 | 3 | use Module::Install::AuthorRequires; |
4 | use 5.008001; | |
4 | use 5.008003; | |
5 | 5 | |
6 | 6 | check_broken_extratests(); |
7 | 7 | check_conflicts(); |
8 | 8 | |
9 | 9 | name 'Moose'; |
10 | perl_version '5.008001'; | |
10 | perl_version '5.008003'; | |
11 | 11 | all_from 'lib/Moose.pm'; |
12 | 12 | license 'perl'; |
13 | 13 | |
14 | 14 | 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'; | |
23 | 24 | |
24 | 25 | test_requires 'Test::More' => '0.88'; |
25 | 26 | test_requires 'Test::Exception' => '0.27'; |
26 | 27 | |
27 | author_requires 'Test::Inline'; | |
28 | 28 | author_requires 'File::Find::Rule'; |
29 | 29 | 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'; | |
30 | 34 | author_requires 'Test::Spelling'; |
31 | author_requires 'Test::Pod::Coverage'; | |
32 | author_requires 'Test::NoTabs'; | |
33 | 35 | |
34 | 36 | if ( is_maintainer() ) { |
35 | 37 | system( $^X, 'author/extract-inline-tests' ); |
47 | 49 | # before a release. |
48 | 50 | sub check_conflicts { |
49 | 51 | 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', | |
68 | 78 | ); |
69 | 79 | |
70 | 80 | my $found = 0; |
0 | Moose version 1.08 | |
0 | Moose version 1.09 | |
1 | 1 | =========================== |
2 | 2 | |
3 | 3 | 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 | ||
0 | 10 | libmoose-perl (1.08-1) unstable; urgency=low |
1 | 11 | |
2 | 12 | * New upstream release |
0 | 0 | Source: libmoose-perl |
1 | 1 | Section: perl |
2 | 2 | Priority: optional |
3 | Build-Depends: debhelper (>= 7), libclass-mop-perl (>= 1.02), | |
3 | Build-Depends: debhelper (>= 7), libclass-mop-perl (>= 1.04), | |
4 | 4 | libdata-optlist-perl, libdatetime-format-mysql-perl, libdbm-deep-perl, |
5 | 5 | libio-string-perl, liblist-moreutils-perl (>= 0.12), liblocale-us-perl, |
6 | 6 | libmodule-refresh-perl, libparams-coerce-perl, libregexp-common-perl, |
7 | 7 | libsub-exporter-perl (>= 0.980), libsub-name-perl, libtask-weaken-perl, |
8 | 8 | libtest-deep-perl, libtest-exception-perl (>= 0.27), libtest-output-perl, |
9 | 9 | 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 | |
11 | 12 | Maintainer: Debian Perl Group <pkg-perl-maintainers@lists.alioth.debian.org> |
12 | 13 | Uploaders: Krzysztof Krzyżaniak (eloy) <eloy@debian.org>, |
13 | 14 | Salvatore Bonaccorso <salvatore.bonaccorso@gmail.com>, |
16 | 17 | Jose Luis Rivas <ghostbar38@gmail.com>, Ryan Niebur <ryan@debian.org>, |
17 | 18 | Niko Tyni <ntyni@iki.fi>, Ansgar Burchardt <ansgar@43-1.org>, |
18 | 19 | Jonathan Yu <jawnsy@cpan.org>, Iulian Udrea <iulian@ubuntu.com> |
19 | Standards-Version: 3.8.4 | |
20 | Standards-Version: 3.9.0 | |
20 | 21 | Homepage: http://search.cpan.org/dist/Moose/ |
21 | 22 | Vcs-Svn: svn://svn.debian.org/pkg-perl/trunk/libmoose-perl/ |
22 | 23 | Vcs-Browser: http://svn.debian.org/viewsvn/pkg-perl/trunk/libmoose-perl/ |
24 | 25 | Package: libmoose-perl |
25 | 26 | Architecture: any |
26 | 27 | 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, | |
28 | 29 | liblist-moreutils-perl, libsub-exporter-perl (>= 0.980), |
29 | 30 | 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 | |
31 | 33 | 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+), | |
37 | 42 | libnamespace-autoclean-perl (<< 0.08+), libpod-elemental-perl (<< 0.093280+) |
38 | 43 | Description: modern Perl object system framework |
39 | 44 | Moose, it's the new Camel. Moose is an extension of the existing Perl 5 object |
3 | 3 | use strict 'vars'; |
4 | 4 | use vars qw{$VERSION}; |
5 | 5 | BEGIN { |
6 | $VERSION = '0.99'; | |
6 | $VERSION = '1.00'; | |
7 | 7 | } |
8 | 8 | |
9 | 9 | # Suspend handler for "redefined" warnings |
8 | 8 | |
9 | 9 | use vars qw{$VERSION @ISA $ISCORE}; |
10 | 10 | BEGIN { |
11 | $VERSION = '0.99'; | |
11 | $VERSION = '1.00'; | |
12 | 12 | @ISA = 'Module::Install::Base'; |
13 | 13 | $ISCORE = 1; |
14 | 14 | } |
5 | 5 | |
6 | 6 | use vars qw{$VERSION @ISA $ISCORE}; |
7 | 7 | BEGIN { |
8 | $VERSION = '0.99'; | |
8 | $VERSION = '1.00'; | |
9 | 9 | @ISA = 'Module::Install::Base'; |
10 | 10 | $ISCORE = 1; |
11 | 11 | } |
7 | 7 | |
8 | 8 | use vars qw{$VERSION @ISA $ISCORE}; |
9 | 9 | BEGIN { |
10 | $VERSION = '0.99'; | |
10 | $VERSION = '1.00'; | |
11 | 11 | @ISA = 'Module::Install::Base'; |
12 | 12 | $ISCORE = 1; |
13 | 13 | } |
5 | 5 | |
6 | 6 | use vars qw{$VERSION @ISA $ISCORE}; |
7 | 7 | BEGIN { |
8 | $VERSION = '0.99'; | |
8 | $VERSION = '1.00'; | |
9 | 9 | @ISA = 'Module::Install::Base'; |
10 | 10 | $ISCORE = 1; |
11 | 11 | } |
5 | 5 | |
6 | 6 | use vars qw{$VERSION @ISA $ISCORE}; |
7 | 7 | BEGIN { |
8 | $VERSION = '0.99'; | |
8 | $VERSION = '1.00'; | |
9 | 9 | @ISA = 'Module::Install::Base'; |
10 | 10 | $ISCORE = 1; |
11 | 11 | } |
5 | 5 | |
6 | 6 | use vars qw{$VERSION @ISA $ISCORE}; |
7 | 7 | BEGIN { |
8 | $VERSION = '0.99'; | |
8 | $VERSION = '1.00'; | |
9 | 9 | @ISA = qw{Module::Install::Base}; |
10 | 10 | $ISCORE = 1; |
11 | 11 | } |
30 | 30 | # This is not enforced yet, but will be some time in the next few |
31 | 31 | # releases once we can make sure it won't clash with custom |
32 | 32 | # Module::Install extensions. |
33 | $VERSION = '0.99'; | |
33 | $VERSION = '1.00'; | |
34 | 34 | |
35 | 35 | # Storage for the pseudo-singleton |
36 | 36 | $MAIN = undef; |
229 | 229 | sub new { |
230 | 230 | my ($class, %args) = @_; |
231 | 231 | |
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 | } | |
234 | 238 | |
235 | 239 | # ignore the prefix on extension modules built from top level. |
236 | 240 | 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 |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | 4 | |
5 | our $VERSION = '1.08'; | |
5 | our $VERSION = '1.09'; | |
6 | 6 | $VERSION = eval $VERSION; |
7 | 7 | our $AUTHORITY = 'cpan:STEVAN'; |
8 | 8 |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | 4 | |
5 | our $VERSION = '1.08'; | |
5 | our $VERSION = '1.09'; | |
6 | 6 | $VERSION = eval $VERSION; |
7 | 7 | our $AUTHORITY = 'cpan:STEVAN'; |
8 | 8 |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | 4 | |
5 | our $VERSION = '1.08'; | |
5 | our $VERSION = '1.09'; | |
6 | 6 | $VERSION = eval $VERSION; |
7 | 7 | our $AUTHORITY = 'cpan:STEVAN'; |
8 | 8 |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | 4 | |
5 | our $VERSION = '1.08'; | |
5 | our $VERSION = '1.09'; | |
6 | 6 | our $XS_VERSION = $VERSION; |
7 | 7 | $VERSION = eval $VERSION; |
8 | 8 | our $AUTHORITY = 'cpan:STEVAN'; |
9 | 9 | |
10 | 10 | use Class::MOP; |
11 | 11 | use List::MoreUtils qw( first_index uniq ); |
12 | use Moose::Deprecated; | |
12 | 13 | use Moose::Util::MetaRole; |
13 | 14 | use Sub::Exporter 0.980; |
14 | 15 | use Sub::Name qw(subname); |
474 | 475 | $export_recorder, |
475 | 476 | $is_reexport, |
476 | 477 | ); |
477 | strict->unimport; | |
478 | warnings->unimport; | |
479 | 478 | }; |
480 | 479 | } |
481 | 480 | |
546 | 545 | |
547 | 546 | return unless Class::MOP::class_of( $options{for_class} ); |
548 | 547 | |
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 | } | |
554 | 555 | |
555 | 556 | Moose::Util::MetaRole::apply_base_class_roles( |
556 | 557 | for_class => $options{for_class}, |
566 | 567 | sub import { |
567 | 568 | strict->import; |
568 | 569 | warnings->import; |
569 | } | |
570 | ||
571 | sub unimport { | |
572 | strict->unimport; | |
573 | warnings->unimport; | |
574 | 570 | } |
575 | 571 | |
576 | 572 | 1; |
651 | 647 | |
652 | 648 | If you pass any parameters for L<Moose::Util::MetaRole>, this method will |
653 | 649 | 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 | |
655 | 651 | C<Moose::Util::MetaRole::apply_base_class_roles> as needed. |
656 | 652 | |
657 | 653 | Note that if any of these methods already exist, they will not be |
697 | 693 | |
698 | 694 | You can also provide parameters for C<Moose::Util::MetaRole::apply_metaroles> |
699 | 695 | 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". | |
701 | 697 | |
702 | 698 | =item B<< Moose::Exporter->build_import_methods(...) >> |
703 | 699 |
14 | 14 | |
15 | 15 | =head2 C<namespace::autoclean> and immutabilize |
16 | 16 | |
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 | |
18 | 18 | definitions by making your class immutable. |
19 | 19 | |
20 | 20 | package Person; |
33 | 33 | The C<use namespace::autoclean> bit is simply good code hygiene, as it removes |
34 | 34 | imported symbols from you class's namespace at the end of your package's |
35 | 35 | 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> | |
37 | 37 | call allows Moose to speed up a lot of things, most notably object |
38 | 38 | construction. The trade-off is that you can no longer change the class |
39 | 39 | definition. |
40 | 40 | |
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>. | |
43 | 44 | |
44 | 45 | =head2 Never override C<new> |
45 | 46 |
14 | 14 | feature. If you encounter a problem and have a solution but don't see |
15 | 15 | it documented here, or think we missed an important feature, please |
16 | 16 | 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 | |
17 | 71 | |
18 | 72 | =head1 1.05 |
19 | 73 |
10 | 10 | released on a schedule. Releases happen as new features and bug fixes |
11 | 11 | are required. |
12 | 12 | |
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. | |
15 | 15 | |
16 | 16 | =head1 DEPRECATION POLICY |
17 | 17 | |
19 | 19 | compatibility. |
20 | 20 | |
21 | 21 | 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>. | |
23 | 23 | |
24 | 24 | Moose then attempts to warn for deprecated features and API changes for |
25 | 25 | a reasonable number of releases before breaking any tested API. |
56 | 56 | =head1 CONTRIBUTING |
57 | 57 | |
58 | 58 | 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. | |
62 | 60 | |
63 | 61 | =cut |
197 | 197 | application. |
198 | 198 | |
199 | 199 | 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. | |
203 | 202 | |
204 | 203 | has 'counter' => (is => 'rw', isa => PositiveInt); |
205 | 204 | |
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: | |
207 | 207 | |
208 | 208 | has 'counts' => (is => 'ro', isa => HashRef[PositiveInt]); |
209 | 209 | |
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. | |
213 | 212 | |
214 | 213 | =head1 COERCION |
215 | 214 | |
426 | 425 | C<MyApp::Types>. Second, load this module in all of your other |
427 | 426 | modules. |
428 | 427 | |
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 | ||
439 | 428 | =head1 AUTHOR |
440 | 429 | |
441 | 430 | Dave Rolsky E<lt>autarch@urth.orgE<gt> |
3 | 3 | use List::Util; |
4 | 4 | use List::MoreUtils; |
5 | 5 | |
6 | our $VERSION = '1.08'; | |
6 | our $VERSION = '1.09'; | |
7 | 7 | $VERSION = eval $VERSION; |
8 | 8 | our $AUTHORITY = 'cpan:STEVAN'; |
9 | 9 |
1 | 1 | package Moose::Meta::Attribute::Native::MethodProvider::Bool; |
2 | 2 | use Moose::Role; |
3 | 3 | |
4 | our $VERSION = '1.08'; | |
4 | our $VERSION = '1.09'; | |
5 | 5 | $VERSION = eval $VERSION; |
6 | 6 | our $AUTHORITY = 'cpan:STEVAN'; |
7 | 7 |
0 | 0 | package Moose::Meta::Attribute::Native::MethodProvider::Code; |
1 | 1 | use Moose::Role; |
2 | 2 | |
3 | our $VERSION = '1.08'; | |
3 | our $VERSION = '1.09'; | |
4 | 4 | $VERSION = eval $VERSION; |
5 | 5 | our $AUTHORITY = 'cpan:STEVAN'; |
6 | 6 |
1 | 1 | package Moose::Meta::Attribute::Native::MethodProvider::Counter; |
2 | 2 | use Moose::Role; |
3 | 3 | |
4 | our $VERSION = '1.08'; | |
4 | our $VERSION = '1.09'; | |
5 | 5 | $VERSION = eval $VERSION; |
6 | 6 | our $AUTHORITY = 'cpan:STEVAN'; |
7 | 7 |
0 | 0 | package Moose::Meta::Attribute::Native::MethodProvider::Hash; |
1 | 1 | use Moose::Role; |
2 | 2 | |
3 | our $VERSION = '1.08'; | |
3 | our $VERSION = '1.09'; | |
4 | 4 | $VERSION = eval $VERSION; |
5 | 5 | our $AUTHORITY = 'cpan:STEVAN'; |
6 | 6 |
0 | 0 | package Moose::Meta::Attribute::Native::MethodProvider::String; |
1 | 1 | use Moose::Role; |
2 | 2 | |
3 | our $VERSION = '1.08'; | |
3 | our $VERSION = '1.09'; | |
4 | 4 | $VERSION = eval $VERSION; |
5 | 5 | our $AUTHORITY = 'cpan:STEVAN'; |
6 | 6 |
1 | 1 | package Moose::Meta::Attribute::Native::Trait::Array; |
2 | 2 | use Moose::Role; |
3 | 3 | |
4 | our $VERSION = '1.08'; | |
4 | our $VERSION = '1.09'; | |
5 | 5 | $VERSION = eval $VERSION; |
6 | 6 | our $AUTHORITY = 'cpan:STEVAN'; |
7 | 7 |
1 | 1 | use Moose::Role; |
2 | 2 | use Moose::Meta::Attribute::Native::MethodProvider::Bool; |
3 | 3 | |
4 | our $VERSION = '1.08'; | |
4 | our $VERSION = '1.09'; | |
5 | 5 | $VERSION = eval $VERSION; |
6 | 6 | our $AUTHORITY = 'cpan:STEVAN'; |
7 | 7 |
1 | 1 | use Moose::Role; |
2 | 2 | use Moose::Meta::Attribute::Native::MethodProvider::Code; |
3 | 3 | |
4 | our $VERSION = '1.08'; | |
4 | our $VERSION = '1.09'; | |
5 | 5 | $VERSION = eval $VERSION; |
6 | 6 | our $AUTHORITY = 'cpan:STEVAN'; |
7 | 7 |
1 | 1 | package Moose::Meta::Attribute::Native::Trait::Counter; |
2 | 2 | use Moose::Role; |
3 | 3 | |
4 | our $VERSION = '1.08'; | |
4 | our $VERSION = '1.09'; | |
5 | 5 | $VERSION = eval $VERSION; |
6 | 6 | our $AUTHORITY = 'cpan:STEVAN'; |
7 | 7 |
1 | 1 | package Moose::Meta::Attribute::Native::Trait::Hash; |
2 | 2 | use Moose::Role; |
3 | 3 | |
4 | our $VERSION = '1.08'; | |
4 | our $VERSION = '1.09'; | |
5 | 5 | $VERSION = eval $VERSION; |
6 | 6 | our $AUTHORITY = 'cpan:STEVAN'; |
7 | 7 |
0 | 0 | package Moose::Meta::Attribute::Native::Trait::Number; |
1 | 1 | use Moose::Role; |
2 | 2 | |
3 | our $VERSION = '1.08'; | |
3 | our $VERSION = '1.09'; | |
4 | 4 | $VERSION = eval $VERSION; |
5 | 5 | our $AUTHORITY = 'cpan:STEVAN'; |
6 | 6 |
0 | 0 | package Moose::Meta::Attribute::Native::Trait::String; |
1 | 1 | use Moose::Role; |
2 | 2 | |
3 | our $VERSION = '1.08'; | |
3 | our $VERSION = '1.09'; | |
4 | 4 | $VERSION = eval $VERSION; |
5 | 5 | our $AUTHORITY = 'cpan:STEVAN'; |
6 | 6 |
2 | 2 | use Moose::Role; |
3 | 3 | use Moose::Util::TypeConstraints; |
4 | 4 | |
5 | our $VERSION = '1.08'; | |
5 | our $VERSION = '1.09'; | |
6 | 6 | $VERSION = eval $VERSION; |
7 | 7 | our $AUTHORITY = 'cpan:STEVAN'; |
8 | 8 |
0 | 0 | package Moose::Meta::Attribute::Native; |
1 | 1 | |
2 | our $VERSION = '1.08'; | |
2 | our $VERSION = '1.09'; | |
3 | 3 | $VERSION = eval $VERSION; |
4 | 4 | our $AUTHORITY = 'cpan:STEVAN'; |
5 | 5 |
8 | 8 | use Try::Tiny; |
9 | 9 | use overload (); |
10 | 10 | |
11 | our $VERSION = '1.08'; | |
11 | our $VERSION = '1.09'; | |
12 | 12 | our $AUTHORITY = 'cpan:STEVAN'; |
13 | 13 | |
14 | use Moose::Deprecated; | |
14 | 15 | use Moose::Meta::Method::Accessor; |
15 | 16 | use Moose::Meta::Method::Delegation; |
16 | 17 | use Moose::Util (); |
130 | 131 | |
131 | 132 | # ... |
132 | 133 | |
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 | } | |
142 | 138 | |
143 | 139 | # NOTE/TODO |
144 | 140 | # This method *must* be able to handle |
157 | 153 | sub clone_and_inherit_options { |
158 | 154 | my ($self, %options) = @_; |
159 | 155 | |
160 | my %copy = %options; | |
161 | ||
162 | my %actual_options; | |
163 | ||
164 | 156 | # NOTE: |
165 | 157 | # we may want to extends a Class::MOP::Attribute |
166 | 158 | # in which case we need to be able to use the |
168 | 160 | # been here. But we allows Moose::Meta::Attribute |
169 | 161 | # instances to changes them. |
170 | 162 | # - 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); | |
181 | 170 | |
182 | 171 | if ($options{isa}) { |
183 | 172 | my $type_constraint; |
190 | 179 | || $self->throw_error("Could not find the type constraint '" . $options{isa} . "'", data => $options{isa}); |
191 | 180 | } |
192 | 181 | |
193 | $actual_options{type_constraint} = $type_constraint; | |
194 | delete $options{isa}; | |
182 | $options{type_constraint} = $type_constraint; | |
195 | 183 | } |
196 | 184 | |
197 | 185 | if ($options{does}) { |
205 | 193 | || $self->throw_error("Could not find the type constraint '" . $options{does} . "'", data => $options{does}); |
206 | 194 | } |
207 | 195 | |
208 | $actual_options{type_constraint} = $type_constraint; | |
209 | delete $options{does}; | |
196 | $options{type_constraint} = $type_constraint; | |
210 | 197 | } |
211 | 198 | |
212 | 199 | # NOTE: |
214 | 201 | # so we can ignore it for them. |
215 | 202 | # - SL |
216 | 203 | if ($self->can('interpolate_class')) { |
217 | ( $actual_options{metaclass}, my @traits ) = $self->interpolate_class(\%options); | |
204 | ( $options{metaclass}, my @traits ) = $self->interpolate_class(\%options); | |
218 | 205 | |
219 | 206 | my %seen; |
220 | 207 | 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); | |
231 | 212 | } |
232 | 213 | |
233 | 214 | sub clone { |
321 | 302 | || $class->throw_error("You cannot have coercion without specifying a type constraint on attribute ($name)", data => $options); |
322 | 303 | $class->throw_error("You cannot have a weak reference to a coerced value on attribute ($name)", data => $options) |
323 | 304 | 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 | } | |
324 | 315 | } |
325 | 316 | |
326 | 317 | if (exists $options->{trigger}) { |
435 | 426 | |
436 | 427 | return $meta_instance->set_slot_value($instance, $slot_name, $value) |
437 | 428 | 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 | } | |
444 | 429 | |
445 | 430 | my $callback = sub { |
446 | 431 | my $val = $self->_coerce_and_verify( shift, $instance );; |
574 | 559 | . "an accessor" |
575 | 560 | ); |
576 | 561 | } |
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 | } | |
577 | 569 | $self->SUPER::_process_accessors(@_); |
578 | 570 | } |
579 | 571 | |
737 | 729 | |
738 | 730 | return $val unless $self->has_type_constraint; |
739 | 731 | |
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; | |
744 | 734 | |
745 | 735 | $self->verify_against_type_constraint($val, instance => $instance); |
746 | 736 | |
1029 | 1019 | the C<clone> method. |
1030 | 1020 | |
1031 | 1021 | 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 | |
1038 | 1028 | subclass's attribute definition. |
1039 | 1029 | |
1040 | 1030 | 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. | |
1042 | 1032 | |
1043 | 1033 | =item B<< $attr->type_constraint >> |
1044 | 1034 |
4 | 4 | |
5 | 5 | use Class::MOP; |
6 | 6 | |
7 | our $VERSION = '1.08'; | |
7 | our $VERSION = '1.09'; | |
8 | 8 | $VERSION = eval $VERSION; |
9 | 9 | our $AUTHORITY = 'cpan:STEVAN'; |
10 | 10 |
11 | 11 | use List::MoreUtils qw( any all uniq first_index ); |
12 | 12 | use Scalar::Util 'weaken', 'blessed'; |
13 | 13 | |
14 | our $VERSION = '1.08'; | |
14 | our $VERSION = '1.09'; | |
15 | 15 | $VERSION = eval $VERSION; |
16 | 16 | our $AUTHORITY = 'cpan:STEVAN'; |
17 | 17 |
3 | 3 | use strict; |
4 | 4 | use warnings; |
5 | 5 | |
6 | our $VERSION = '1.08'; | |
6 | our $VERSION = '1.09'; | |
7 | 7 | $VERSION = eval $VERSION; |
8 | 8 | our $AUTHORITY = 'cpan:STEVAN'; |
9 | 9 |
3 | 3 | use strict; |
4 | 4 | use warnings; |
5 | 5 | |
6 | our $VERSION = '1.08'; | |
6 | our $VERSION = '1.09'; | |
7 | 7 | $VERSION = eval $VERSION; |
8 | 8 | our $AUTHORITY = 'cpan:STEVAN'; |
9 | 9 | |
110 | 110 | return $attr->should_coerce; |
111 | 111 | } |
112 | 112 | |
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 | } | |
118 | 147 | |
119 | 148 | sub _inline_pre_body { '' } |
120 | 149 | sub _inline_post_body { '' } |
136 | 165 | |
137 | 166 | my $attr = $self->associated_attribute; |
138 | 167 | |
139 | return '' unless $attr->should_coerce; | |
168 | return '' unless $attr->should_coerce && $attr->type_constraint->has_coercion; | |
140 | 169 | return "$value = \$attr->type_constraint->coerce($value);"; |
141 | 170 | } |
142 | 171 |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | 4 | |
5 | our $VERSION = '1.08'; | |
5 | our $VERSION = '1.09'; | |
6 | 6 | $VERSION = eval $VERSION; |
7 | 7 | our $AUTHORITY = 'cpan:STEVAN'; |
8 | 8 |
5 | 5 | |
6 | 6 | use Scalar::Util 'blessed', 'weaken', 'looks_like_number', 'refaddr'; |
7 | 7 | |
8 | our $VERSION = '1.08'; | |
8 | our $VERSION = '1.09'; | |
9 | 9 | our $AUTHORITY = 'cpan:STEVAN'; |
10 | 10 | |
11 | 11 | use base 'Moose::Meta::Method', |
6 | 6 | use Carp 'confess'; |
7 | 7 | use Scalar::Util 'blessed', 'weaken'; |
8 | 8 | |
9 | our $VERSION = '1.08'; | |
9 | our $VERSION = '1.09'; | |
10 | 10 | $VERSION = eval $VERSION; |
11 | 11 | our $AUTHORITY = 'cpan:STEVAN'; |
12 | 12 |
7 | 7 | use Scalar::Util 'blessed', 'weaken'; |
8 | 8 | use Try::Tiny (); |
9 | 9 | |
10 | our $VERSION = '1.08'; | |
10 | our $VERSION = '1.09'; | |
11 | 11 | $VERSION = eval $VERSION; |
12 | 12 | our $AUTHORITY = 'cpan:STEVAN'; |
13 | 13 |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | 4 | |
5 | our $VERSION = '1.08'; | |
5 | our $VERSION = '1.09'; | |
6 | 6 | $VERSION = eval $VERSION; |
7 | 7 | our $AUTHORITY = 'cpan:STEVAN'; |
8 | 8 |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | 4 | |
5 | our $VERSION = '1.08'; | |
5 | our $VERSION = '1.09'; | |
6 | 6 | $VERSION = eval $VERSION; |
7 | 7 | our $AUTHORITY = 'cpan:STEVAN'; |
8 | 8 |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | 4 | |
5 | our $VERSION = '1.08'; | |
5 | our $VERSION = '1.09'; | |
6 | 6 | our $AUTHORITY = 'cpan:STEVAN'; |
7 | 7 | |
8 | 8 | use base 'Class::MOP::Mixin::AttributeCore'; |
7 | 7 | |
8 | 8 | use Moose::Meta::Role::Composite; |
9 | 9 | |
10 | our $VERSION = '1.08'; | |
10 | our $VERSION = '1.09'; | |
11 | 11 | $VERSION = eval $VERSION; |
12 | 12 | our $AUTHORITY = 'cpan:STEVAN'; |
13 | 13 |
6 | 6 | use Moose::Util 'english_list'; |
7 | 7 | use Scalar::Util 'weaken', 'blessed'; |
8 | 8 | |
9 | our $VERSION = '1.08'; | |
9 | our $VERSION = '1.09'; | |
10 | 10 | $VERSION = eval $VERSION; |
11 | 11 | our $AUTHORITY = 'cpan:STEVAN'; |
12 | 12 |
5 | 5 | |
6 | 6 | use Scalar::Util 'blessed'; |
7 | 7 | |
8 | our $VERSION = '1.08'; | |
8 | our $VERSION = '1.09'; | |
9 | 9 | $VERSION = eval $VERSION; |
10 | 10 | our $AUTHORITY = 'cpan:STEVAN'; |
11 | 11 |
5 | 5 | |
6 | 6 | use Scalar::Util 'blessed'; |
7 | 7 | |
8 | our $VERSION = '1.08'; | |
8 | our $VERSION = '1.09'; | |
9 | 9 | $VERSION = eval $VERSION; |
10 | 10 | our $AUTHORITY = 'cpan:STEVAN'; |
11 | 11 |
3 | 3 | use warnings; |
4 | 4 | use metaclass; |
5 | 5 | |
6 | our $VERSION = '1.08'; | |
6 | our $VERSION = '1.09'; | |
7 | 7 | $VERSION = eval $VERSION; |
8 | 8 | our $AUTHORITY = 'cpan:STEVAN'; |
9 | 9 |
6 | 6 | use List::MoreUtils 'all'; |
7 | 7 | use Scalar::Util 'blessed', 'weaken'; |
8 | 8 | |
9 | our $VERSION = '1.08'; | |
9 | our $VERSION = '1.09'; | |
10 | 10 | our $AUTHORITY = 'cpan:STEVAN'; |
11 | 11 | |
12 | 12 | use base 'Moose::Meta::Mixin::AttributeCore'; |
5 | 5 | |
6 | 6 | use Scalar::Util 'blessed'; |
7 | 7 | |
8 | our $VERSION = '1.08'; | |
8 | our $VERSION = '1.09'; | |
9 | 9 | $VERSION = eval $VERSION; |
10 | 10 | our $AUTHORITY = 'cpan:STEVAN'; |
11 | 11 |
7 | 7 | |
8 | 8 | use base qw(Moose::Meta::Role::Method::Required); |
9 | 9 | |
10 | our $VERSION = '1.08'; | |
10 | our $VERSION = '1.09'; | |
11 | 11 | $VERSION = eval $VERSION; |
12 | 12 | our $AUTHORITY = 'cpan:STEVAN'; |
13 | 13 |
9 | 9 | |
10 | 10 | use base qw(Class::MOP::Object); |
11 | 11 | |
12 | our $VERSION = '1.08'; | |
12 | our $VERSION = '1.09'; | |
13 | 13 | $VERSION = eval $VERSION; |
14 | 14 | our $AUTHORITY = 'cpan:STEVAN'; |
15 | 15 |
3 | 3 | use strict; |
4 | 4 | use warnings; |
5 | 5 | |
6 | our $VERSION = '1.08'; | |
6 | our $VERSION = '1.09'; | |
7 | 7 | $VERSION = eval $VERSION; |
8 | 8 | our $AUTHORITY = 'cpan:STEVAN'; |
9 | 9 |
8 | 8 | use Carp 'confess'; |
9 | 9 | use Devel::GlobalDestruction 'in_global_destruction'; |
10 | 10 | |
11 | our $VERSION = '1.08'; | |
11 | our $VERSION = '1.09'; | |
12 | 12 | $VERSION = eval $VERSION; |
13 | 13 | our $AUTHORITY = 'cpan:STEVAN'; |
14 | 14 | |
389 | 389 | } |
390 | 390 | |
391 | 391 | 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 | } | |
400 | 392 | |
401 | 393 | ## ------------------------------------------------------------------ |
402 | 394 | ## role construction |
6 | 6 | |
7 | 7 | use Scalar::Util 'blessed'; |
8 | 8 | |
9 | our $VERSION = '1.08'; | |
9 | our $VERSION = '1.09'; | |
10 | 10 | $VERSION = eval $VERSION; |
11 | 11 | our $AUTHORITY = 'cpan:STEVAN'; |
12 | 12 |
7 | 7 | use Moose::Meta::Attribute; |
8 | 8 | use Moose::Util::TypeConstraints (); |
9 | 9 | |
10 | our $VERSION = '1.08'; | |
10 | our $VERSION = '1.09'; | |
11 | 11 | $VERSION = eval $VERSION; |
12 | 12 | our $AUTHORITY = 'cpan:STEVAN'; |
13 | 13 |
6 | 6 | use Scalar::Util 'blessed'; |
7 | 7 | use Moose::Util::TypeConstraints (); |
8 | 8 | |
9 | our $VERSION = '1.08'; | |
9 | our $VERSION = '1.09'; | |
10 | 10 | $VERSION = eval $VERSION; |
11 | 11 | our $AUTHORITY = 'cpan:STEVAN'; |
12 | 12 |
9 | 9 | |
10 | 10 | use Moose::Util::TypeConstraints (); |
11 | 11 | |
12 | our $VERSION = '1.08'; | |
12 | our $VERSION = '1.09'; | |
13 | 13 | $VERSION = eval $VERSION; |
14 | 14 | our $AUTHORITY = 'cpan:STEVAN'; |
15 | 15 |
5 | 5 | |
6 | 6 | use Moose::Util::TypeConstraints (); |
7 | 7 | |
8 | our $VERSION = '1.08'; | |
8 | our $VERSION = '1.09'; | |
9 | 9 | $VERSION = eval $VERSION; |
10 | 10 | our $AUTHORITY = 'cpan:STEVAN'; |
11 | 11 |
3 | 3 | use warnings; |
4 | 4 | use metaclass; |
5 | 5 | |
6 | our $VERSION = '1.08'; | |
6 | our $VERSION = '1.09'; | |
7 | 7 | $VERSION = eval $VERSION; |
8 | 8 | our $AUTHORITY = 'cpan:STEVAN'; |
9 | 9 |
7 | 7 | use Moose::Util::TypeConstraints; |
8 | 8 | use Moose::Meta::TypeConstraint::Parameterizable; |
9 | 9 | |
10 | our $VERSION = '1.08'; | |
10 | our $VERSION = '1.09'; | |
11 | 11 | $VERSION = eval $VERSION; |
12 | 12 | our $AUTHORITY = 'cpan:STEVAN'; |
13 | 13 |
6 | 6 | |
7 | 7 | use Scalar::Util 'blessed'; |
8 | 8 | |
9 | our $VERSION = '1.08'; | |
9 | our $VERSION = '1.09'; | |
10 | 10 | $VERSION = eval $VERSION; |
11 | 11 | our $AUTHORITY = 'cpan:STEVAN'; |
12 | 12 |
6 | 6 | use Scalar::Util 'blessed'; |
7 | 7 | use Moose::Util::TypeConstraints (); |
8 | 8 | |
9 | our $VERSION = '1.08'; | |
9 | our $VERSION = '1.09'; | |
10 | 10 | $VERSION = eval $VERSION; |
11 | 11 | our $AUTHORITY = 'cpan:STEVAN'; |
12 | 12 |
8 | 8 | |
9 | 9 | use List::Util qw(first); |
10 | 10 | |
11 | our $VERSION = '1.08'; | |
11 | our $VERSION = '1.09'; | |
12 | 12 | $VERSION = eval $VERSION; |
13 | 13 | our $AUTHORITY = 'cpan:STEVAN'; |
14 | 14 |
14 | 14 | |
15 | 15 | use base qw(Class::MOP::Object); |
16 | 16 | |
17 | our $VERSION = '1.08'; | |
17 | our $VERSION = '1.09'; | |
18 | 18 | $VERSION = eval $VERSION; |
19 | 19 | our $AUTHORITY = 'cpan:STEVAN'; |
20 | 20 |
11 | 11 | use if ( not our $__mx_is_compiled ), 'Moose::Meta::Class'; |
12 | 12 | use if ( not our $__mx_is_compiled ), metaclass => 'Moose::Meta::Class'; |
13 | 13 | |
14 | our $VERSION = '1.08'; | |
14 | our $VERSION = '1.09'; | |
15 | 15 | $VERSION = eval $VERSION; |
16 | 16 | our $AUTHORITY = 'cpan:STEVAN'; |
17 | 17 |
6 | 6 | |
7 | 7 | use Sub::Exporter; |
8 | 8 | |
9 | our $VERSION = '1.08'; | |
9 | our $VERSION = '1.09'; | |
10 | 10 | $VERSION = eval $VERSION; |
11 | 11 | our $AUTHORITY = 'cpan:STEVAN'; |
12 | 12 |
3 | 3 | use warnings; |
4 | 4 | use Scalar::Util 'blessed'; |
5 | 5 | |
6 | our $VERSION = '1.08'; | |
6 | our $VERSION = '1.09'; | |
7 | 7 | $VERSION = eval $VERSION; |
8 | 8 | our $AUTHORITY = 'cpan:STEVAN'; |
9 | 9 | |
10 | 10 | use List::MoreUtils qw( all ); |
11 | 11 | use List::Util qw( first ); |
12 | use Moose::Deprecated; | |
12 | 13 | |
13 | 14 | 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 | ||
14 | 21 | goto &apply_metaroles; |
15 | 22 | } |
16 | 23 | |
35 | 42 | sub _fixup_old_style_args { |
36 | 43 | my $args = shift; |
37 | 44 | |
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 | ); | |
39 | 52 | |
40 | 53 | $args->{for} = delete $args->{for_class} |
41 | 54 | if exists $args->{for_class}; |
3 | 3 | use warnings; |
4 | 4 | |
5 | 5 | use Class::MOP; |
6 | use Moose::Deprecated; | |
6 | 7 | use Scalar::Util 'blessed', 'looks_like_number'; |
7 | 8 | |
8 | our $VERSION = '1.08'; | |
9 | our $VERSION = '1.09'; | |
9 | 10 | $VERSION = eval $VERSION; |
10 | 11 | our $AUTHORITY = 'cpan:STEVAN'; |
11 | 12 | |
35 | 36 | |
36 | 37 | sub Object { blessed($_[0]) && blessed($_[0]) ne 'Regexp' } |
37 | 38 | |
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 | } | |
39 | 47 | |
40 | 48 | sub ClassName { |
41 | 49 | return Class::MOP::is_class_loaded( $_[0] ); |
5 | 5 | use Scalar::Util qw( blessed reftype ); |
6 | 6 | use Moose::Exporter; |
7 | 7 | |
8 | our $VERSION = '1.08'; | |
8 | our $VERSION = '1.09'; | |
9 | 9 | $VERSION = eval $VERSION; |
10 | 10 | our $AUTHORITY = 'cpan:STEVAN'; |
11 | 11 | |
24 | 24 | |
25 | 25 | ## -------------------------------------------------------- |
26 | 26 | |
27 | use Moose::Deprecated; | |
27 | 28 | use Moose::Meta::TypeConstraint; |
28 | 29 | use Moose::Meta::TypeConstraint::Union; |
29 | 30 | use Moose::Meta::TypeConstraint::Parameterized; |
274 | 275 | |
275 | 276 | # back-compat version, called without sugar |
276 | 277 | 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 | ||
277 | 284 | return _create_type_constraint( $_[0], undef, $_[1] ); |
278 | 285 | } |
279 | 286 | |
293 | 300 | # |
294 | 301 | # subtype 'Parent', sub { where }; |
295 | 302 | 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 | ||
296 | 309 | return _create_type_constraint( undef, @_ ); |
297 | 310 | } |
298 | 311 | |
300 | 313 | # subtype 'Parent', sub { where }, sub { message }, sub { optimized }; |
301 | 314 | if ( scalar @_ >= 3 && all { ( reftype($_) || '' ) eq 'CODE' } |
302 | 315 | @_[ 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 | ||
303 | 322 | return _create_type_constraint( undef, @_ ); |
304 | 323 | } |
305 | 324 | |
306 | 325 | # subtype 'Name', 'Parent', ... |
307 | 326 | 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 | ||
308 | 333 | return _create_type_constraint(@_); |
309 | 334 | } |
310 | 335 | |
572 | 597 | |
573 | 598 | my $valid_chars = qr{[\w:\.]}; |
574 | 599 | 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 | ||
589 | 647 | |
590 | 648 | sub _parse_parameterized_type_constraint { |
591 | 649 | { no warnings 'void'; $any; } # force capture of interpolated lexical |
7 | 7 | use Scalar::Util 'blessed'; |
8 | 8 | use Class::MOP 0.60; |
9 | 9 | |
10 | our $VERSION = '1.08'; | |
10 | our $VERSION = '1.09'; | |
11 | 11 | $VERSION = eval $VERSION; |
12 | 12 | our $AUTHORITY = 'cpan:STEVAN'; |
13 | 13 | |
17 | 17 | search_class_by_role |
18 | 18 | ensure_all_roles |
19 | 19 | apply_all_roles |
20 | with_traits | |
20 | 21 | get_all_init_args |
21 | 22 | get_all_attribute_values |
22 | 23 | resolve_metatrait_alias |
133 | 134 | else { |
134 | 135 | Moose::Meta::Role->combine(@role_metas)->apply($meta); |
135 | 136 | } |
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; | |
136 | 147 | } |
137 | 148 | |
138 | 149 | # instance deconstruction ... |
344 | 355 | This function is similar to L</apply_all_roles>, but only applies roles that |
345 | 356 | C<$applicant> does not already consume. |
346 | 357 | |
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 | ||
347 | 363 | =item B<get_all_attribute_values($meta, $instance)> |
348 | 364 | |
349 | 365 | Returns a hash reference containing all of the C<$instance>'s |
3 | 3 | |
4 | 4 | use 5.008; |
5 | 5 | |
6 | our $VERSION = '1.08'; | |
6 | our $VERSION = '1.09'; | |
7 | 7 | $VERSION = eval $VERSION; |
8 | 8 | our $AUTHORITY = 'cpan:STEVAN'; |
9 | 9 | |
10 | 10 | use Scalar::Util 'blessed'; |
11 | 11 | use Carp 'confess'; |
12 | 12 | |
13 | use Moose::Deprecated; | |
13 | 14 | use Moose::Exporter; |
14 | 15 | |
15 | 16 | use Class::MOP 0.94; |
132 | 133 | # This used to be called as a function. This hack preserves |
133 | 134 | # backwards compatibility. |
134 | 135 | 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 | ||
135 | 141 | return __PACKAGE__->init_meta( |
136 | 142 | for_class => $_[0], |
137 | 143 | base_class => $_[1], |
974 | 980 | |
975 | 981 | An alias for C<confess>, used by internally by Moose. |
976 | 982 | |
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 | ||
1004 | 983 | =head2 The MooseX:: namespace |
1005 | 984 | |
1006 | 985 | Generally if you're writing an extension I<for> Moose itself you'll want |
1011 | 990 | and C<DBIx::> namespaces that perform the same function for C<LWP> and C<DBI> |
1012 | 991 | respectively. |
1013 | 992 | |
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 | ||
1014 | 1020 | =head1 CAVEATS |
1015 | 1021 | |
1016 | 1022 | =over 4 |
8 | 8 | use List::MoreUtils 'all'; |
9 | 9 | use Moose::Util 'does_role', 'find_meta'; |
10 | 10 | |
11 | our $VERSION = '1.08'; | |
11 | our $VERSION = '1.09'; | |
12 | 12 | $VERSION = eval $VERSION; |
13 | 13 | our $AUTHORITY = 'cpan:STEVAN'; |
14 | 14 |
4 | 4 | |
5 | 5 | use Class::MOP; |
6 | 6 | |
7 | our $VERSION = '1.08'; | |
7 | our $VERSION = '1.09'; | |
8 | 8 | $VERSION = eval $VERSION; |
9 | 9 | our $AUTHORITY = 'cpan:STEVAN'; |
10 | 10 |
21 | 21 | ::ok($warn, '... got a warning'); |
22 | 22 | ::like($warn, qr/Argument \"hello\" isn\'t numeric in addition \(\+\)/, '.. and it is the right warning'); |
23 | 23 | } |
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 | } | |
40 | 24 | } |
41 | 25 | |
42 | 26 | # and for roles ... |
59 | 43 | ::ok($warn, '... got a warning'); |
60 | 44 | ::like($warn, qr/Argument \"hello\" isn\'t numeric in addition \(\+\)/, '.. and it is the right warning'); |
61 | 45 | } |
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 | } | |
78 | 46 | } |
79 | 47 | |
80 | 48 | # and for exporters |
82 | 50 | package Bar; |
83 | 51 | use Moose::Exporter; |
84 | 52 | |
85 | eval '$foo2 = 5;'; | |
53 | eval '$foo = 5;'; | |
86 | 54 | ::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'); | |
88 | 56 | |
89 | 57 | { |
90 | 58 | my $warn; |
97 | 65 | ::ok($warn, '... got a warning'); |
98 | 66 | ::like($warn, qr/Argument \"hello\" isn\'t numeric in addition \(\+\)/, '.. and it is the right warning'); |
99 | 67 | } |
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 | } | |
116 | 68 | } |
117 | 69 | |
118 | 70 | done_testing; |
7 | 7 | |
8 | 8 | |
9 | 9 | { |
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 | ||
10 | 18 | package Thing; |
11 | 19 | use Moose; |
12 | 20 | |
42 | 50 | |
43 | 51 | # this one will work here .... |
44 | 52 | has 'fail' => (isa => 'CodeRef', is => 'bare'); |
45 | has 'other_fail' => (is => 'bare'); | |
53 | has 'other_fail' => (metaclass => 'Thing::Meta::Attribute', is => 'bare', trigger => sub { }); | |
46 | 54 | |
47 | 55 | package Bar; |
48 | 56 | 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 | #!/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; |
30 | 30 | stderr_like(sub { $foo_meta->add_attribute(e => (is => 'rw')) }, |
31 | 31 | qr/^You are overwriting a locally defined method \(e\) with an accessor/, 'accessor overriding gives proper warning'); |
32 | 32 | |
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 | ||
33 | 36 | 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; |
193 | 193 | # sugar was indistinguishable from calling directly. |
194 | 194 | |
195 | 195 | { |
196 | no warnings 'redefine'; | |
197 | *Moose::Deprecated::deprecated = sub { return }; | |
198 | } | |
199 | ||
200 | { | |
196 | 201 | my $type = type( 'Number2', sub { Scalar::Util::looks_like_number($_) } ); |
197 | 202 | |
198 | 203 | ok( $type->check(5), '... this is a Num' ); |
17 | 17 | |
18 | 18 | package MyFramework; |
19 | 19 | use Moose; |
20 | use Moose::Deprecated -api_version => '0.55'; | |
20 | 21 | |
21 | 22 | sub import { |
22 | 23 | my $CALLER = caller(); |
110 | 110 | use Moose (); |
111 | 111 | |
112 | 112 | sub wrapped2 { |
113 | my $caller = shift; | |
113 | my $caller = shift->name; | |
114 | 114 | return $caller . ' called wrapped2'; |
115 | 115 | } |
116 | 116 | |
119 | 119 | } |
120 | 120 | |
121 | 121 | 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', | |
125 | 125 | ); |
126 | 126 | } |
127 | 127 | |
261 | 261 | use Moose (); |
262 | 262 | |
263 | 263 | sub has { |
264 | my $caller = shift; | |
264 | my $caller = shift->name; | |
265 | 265 | return $caller . ' called has'; |
266 | 266 | } |
267 | 267 | |
268 | 268 | Moose::Exporter->setup_import_methods( |
269 | with_caller => ['has'], | |
270 | also => 'Moose', | |
269 | with_meta => ['has'], | |
270 | also => 'Moose', | |
271 | 271 | ); |
272 | 272 | } |
273 | 273 | |
297 | 297 | ::stderr_like { |
298 | 298 | Moose::Exporter->setup_import_methods( |
299 | 299 | also => ['Moose'], |
300 | with_caller => ['does_not_exist'], | |
300 | with_meta => ['does_not_exist'], | |
301 | 301 | ); |
302 | 302 | } qr/^Trying to export undefined sub NonExistentExport::does_not_exist/, |
303 | 303 | "warns when a non-existent method is requested to be exported"; |
315 | 315 | { |
316 | 316 | package AllOptions; |
317 | 317 | use Moose (); |
318 | use Moose::Deprecated -api_version => '0.88'; | |
318 | 319 | use Moose::Exporter; |
319 | 320 | |
320 | 321 | Moose::Exporter->setup_import_methods( |
571 | 571 | my %p = @_; |
572 | 572 | Moose->init_meta(%p); |
573 | 573 | return Moose::Util::MetaRole::apply_metaroles( |
574 | for_class => $p{for_class}, | |
574 | for => $p{for_class}, | |
575 | 575 | # Causes us to recurse through init_meta, as we have to |
576 | 576 | # load MyMetaclassRole from disk. |
577 | metaclass_roles => [qw/MyMetaclassRole/], | |
577 | class_metaroles => { class => [qw/MyMetaclassRole/] }, | |
578 | 578 | ); |
579 | 579 | } |
580 | 580 | } |
25 | 25 | use Moose::Exporter; |
26 | 26 | |
27 | 27 | 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'], | |
32 | 34 | ); |
33 | 35 | } |
34 | 36 | |
49 | 51 | use Moose (); |
50 | 52 | use Moose::Exporter; |
51 | 53 | |
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)], | |
59 | 63 | ); |
60 | 64 | |
61 | 65 | sub init_meta { |
113 | 113 | sub init_meta { |
114 | 114 | my ( $self, %options ) = @_; |
115 | 115 | return Moose::Util::MetaRole::apply_metaroles( |
116 | for_class => Moose::Role->init_meta(%options), | |
116 | for => Moose::Role->init_meta(%options), | |
117 | 117 | role_metaroles => { |
118 | 118 | role => ['Role::WithCustomApplication'], |
119 | 119 | application_to_class => |
12 | 12 | |
13 | 13 | use Moose::Util::MetaRole; |
14 | 14 | |
15 | { | |
16 | no warnings 'redefine'; | |
17 | *Moose::Deprecated::deprecated = sub { return }; | |
18 | } | |
15 | 19 | |
16 | 20 | { |
17 | 21 | 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; |
4 | 4 | use Test::More; |
5 | 5 | |
6 | 6 | 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)], | |
9 | 9 | ); |
10 | 10 | |
11 | 11 | sub with_prototype (&) { |
20 | 20 | $code->(); |
21 | 21 | } |
22 | 22 | |
23 | 1;⏎ | |
23 | 1; |
13 | 13 | plan tests => scalar @modules; |
14 | 14 | |
15 | 15 | my %trustme = ( |
16 | 'Moose::Exporter' => ['unimport'], | |
17 | 16 | 'Moose::Meta::Attribute' => [ |
18 | 17 | qw( interpolate_class |
19 | 18 | throw_error |
200 | 200 | utils |
201 | 201 | whitelist |
202 | 202 | Whitelist |
203 | whitelisted | |
203 | 204 | workflow |
204 | 205 | |
205 | 206 | ## other jargon |
38 | 38 | MooseX::AttributeCloner |
39 | 39 | MooseX::AttributeDefaults |
40 | 40 | MooseX::AttributeHelpers |
41 | MooseX::AttributeIndexes | |
42 | 41 | MooseX::AttributeInflate |
43 | 42 | MooseX::Attributes::Curried |
43 | MooseX::AutoDestruct | |
44 | 44 | MooseX::Blessed::Reconstruct |
45 | MooseX::CascadeClearing | |
46 | 45 | MooseX::ClassAttribute |
47 | 46 | MooseX::Clone |
48 | 47 | MooseX::ConfigFromFile |
55 | 54 | MooseX::DeepAccessors |
56 | 55 | MooseX::Dumper |
57 | 56 | MooseX::Emulate::Class::Accessor::Fast |
58 | MooseX::Error::Exception::Class | |
59 | 57 | MooseX::Error::Trap |
60 | MooseX::FSM | |
61 | 58 | MooseX::FileAttribute |
62 | 59 | MooseX::File_or_DB::Storage |
63 | 60 | MooseX::FollowPBP |
80 | 77 | MooseX::MakeImmutable |
81 | 78 | MooseX::Mangle |
82 | 79 | MooseX::MarkAsMethods |
83 | MooseX::Meta::Attribute::Index | |
84 | MooseX::Meta::Attribute::Lvalue | |
85 | 80 | MooseX::Meta::TypeConstraint::ForceCoercion |
86 | 81 | MooseX::Meta::TypeConstraint::Intersection |
87 | 82 | MooseX::MetaDescription |
91 | 86 | MooseX::MultiInitArg |
92 | 87 | MooseX::MultiMethods |
93 | 88 | MooseX::MutatorAttributes |
94 | MooseX::Net::API | |
95 | 89 | MooseX::NonMoose |
96 | 90 | MooseX::Object::Pluggable |
97 | 91 | MooseX::Param |
189 | 183 | Markdent |
190 | 184 | namespace::autoclean |
191 | 185 | NetHack::Item |
186 | Net::HTTP::API | |
192 | 187 | Net::Twitter |
193 | 188 | Path::Router |
194 | 189 | Pod::Elemental |