-
Notifications
You must be signed in to change notification settings - Fork 2
/
README
47 lines (33 loc) · 1.16 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
NAME
MooseX::Types::LoadableClass - ClassName type constraint with coercion
to load the class.
SYNOPSIS
package MyClass;
use Moose;
use MooseX::Types::LoadableClass qw/ LoadableClass /;
has foobar_class => (
is => 'ro',
required => 1,
isa => LoadableClass,
coerce => 1,
);
MyClass->new(foobar_class => 'FooBar'); # FooBar.pm is loaded or an
# exception is thrown.
DESCRIPTION
use Moose::Util::TypeConstraints;
my $tc = subtype as ClassName;
coerce $tc, from Str, via { Class::MOP::load_class($_); $_ };
I've written those three lines of code quite a lot of times, in quite a
lot of places.
Now I don't have to.
TYPES EXPORTED
LoadableClass
A normal class / package.
LoadableRole
Like "LoadableClass", except the loaded package must be a Moose::Role.
AUTHORS
Tomas Doran (t0m) "<bobtfish@bobtfish.net>"
Florian Ragwitz (rafl) "<rafl@debian.org>"
COPYRIGHT AND LICENSE
Copyright (c) 2010 the above named authors.
Licensed under the same terms as perl itself.