1MooseX::Types::LoadableUCslearssC(o3n)tributed Perl DocuMmoeonsteaXt:i:oTnypes::LoadableClass(3)
2
3
4

NAME

6       MooseX::Types::LoadableClass - ClassName type constraint with coercion
7       to load the class.
8

SYNOPSIS

10           package MyClass;
11           use Moose;
12           use MooseX::Types::LoadableClass qw/ LoadableClass /;
13
14           has foobar_class => (
15               is => 'ro',
16               required => 1,
17               isa => LoadableClass,
18               coerce => 1,
19           );
20
21           MyClass->new(foobar_class => 'FooBar'); # FooBar.pm is loaded or an
22                                                   # exception is thrown.
23

DESCRIPTION

25           use Moose::Util::TypeConstraints;
26
27           my $tc = subtype as ClassName;
28           coerce $tc, from Str, via { Class::MOP::load_class($_); $_ };
29
30       I've written those three lines of code quite a lot of times, in quite a
31       lot of places.
32
33       Now I don't have to.
34

TYPES EXPORTED

36   LoadableClass
37       A normal class / package.
38
39   LoadableRole
40       Like "LoadableClass", except the loaded package must be a Moose::Role.
41

AUTHORS

43       Tomas Doran (t0m) "<bobtfish@bobtfish.net>"
44
45       Florian Ragwitz (rafl) "<rafl@debian.org>"
46
48       Copyright (c) 2010 the above named authors.
49
50       Licensed under the same terms as perl itself.
51
52
53
54perl v5.12.3                      2011-08-05   MooseX::Types::LoadableClass(3)
Impressum