1 package MooseX::LazyRequire::Meta::Attribute::Trait::LazyRequire;
7 use MooseX::Types::Moose qw/Bool/;
8 use namespace::autoclean;
10 has lazy_required => (
17 after _process_options => sub {
18 my ($class, $name, $options) = @_;
20 if (exists $options->{lazy_require}) {
21 cluck "deprecated option 'lazy_require' used. use 'lazy_required' instead.";
22 $options->{lazy_required} = delete $options->{lazy_require};
25 return unless $options->{lazy_required};
28 "You may not use both a builder or a default and lazy_required for one attribute ($name)",
30 ) if $options->{builder};
32 $options->{ lazy } = 1;
33 $options->{ required } = 1;
34 $options->{ default } = sub {
35 confess "Attribute $name must be provided before calling reader"
40 Moose::Meta::Attribute::Custom::Trait::LazyRequire;
42 sub register_implementation { 'MooseX::LazyRequire::Meta::Attribute::Trait::LazyRequire' }
52 MooseX::LazyRequire::Meta::Attribute::Trait::LazyRequire
60 Florian Ragwitz <rafl@debian.org>
62 =head1 COPYRIGHT AND LICENSE
64 This software is copyright (c) 2009 by Florian Ragwitz.
66 This is free software; you can redistribute it and/or modify it under
67 the same terms as the Perl 5 programming language system itself.