[libmoosex-lazyrequire-perl] 04/06: Add docs.
Intrigeri
intrigeri at moszumanska.debian.org
Wed Aug 27 21:25:15 UTC 2014
This is an automated email from the git hooks/post-receive script.
intrigeri pushed a commit to annotated tag 0.01
in repository libmoosex-lazyrequire-perl.
commit 0804f0e04ff4fc87d4c1f90135ae52875597aafd
Author: Florian Ragwitz <rafl at debian.org>
Date: Thu Aug 13 02:15:26 2009 +0200
Add docs.
---
lib/MooseX/LazyRequire.pm | 54 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/lib/MooseX/LazyRequire.pm b/lib/MooseX/LazyRequire.pm
index d95aa5e..d55138e 100644
--- a/lib/MooseX/LazyRequire.pm
+++ b/lib/MooseX/LazyRequire.pm
@@ -1,9 +1,57 @@
package MooseX::LazyRequire;
+# ABSTRACT: Required attributes which fail only when trying to use them
use Moose::Exporter;
use aliased 'MooseX::LazyRequire::Meta::Attribute::Trait::LazyRequire';
use namespace::autoclean;
+=head1 SYNOPSIS
+
+ package Foo;
+
+ use Moose;
+ use MooseX::LazyRequire;
+
+ has foo => (
+ is => 'ro',
+ lazy_require => 1,
+ );
+
+ has bar => (
+ is => 'ro',
+ builder => '_build_bar',
+ );
+
+ sub _build_bar { shift->foo }
+
+
+ Foo->new(foo => 42); # succeeds, foo and bar will be 42
+ Foo->new(bar => 42); # succeeds, bar will be 42
+ Foo->new; # fails, neither foo nor bare were given
+
+=head1 DESCRIPTION
+
+This module adds a C<lazy_require> option to Moose attribute declarations.
+
+The reader methods for all attributes with that option will throw an exception
+unless a value for the attributes was provided earlier by a constructor
+parameter or through a writer method.
+
+=head1 CAVEATS
+
+Apparently Moose roles don't have an attribute metaclass, so this module can't
+easily apply its magic to attributes defined in roles. If you want to use
+C<lazy_require> in role attributes, you'll have to apply the attribute trait
+yourself:
+
+ has foo => (
+ traits => ['LazyRequire'],
+ is => 'ro',
+ lazy_require => 1,
+ );
+
+=cut
+
Moose::Exporter->setup_import_methods;
sub init_meta {
@@ -14,4 +62,10 @@ sub init_meta {
);
}
+=begin Pod::Coverage
+
+init_meta
+
+=end Pod::Coverage
+
1;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmoosex-lazyrequire-perl.git
More information about the Pkg-perl-cvs-commits
mailing list