[libmoosex-lazyrequire-perl] 01/03: Rename lazy_require to lazy_required.

Intrigeri intrigeri at moszumanska.debian.org
Wed Aug 27 21:25:16 UTC 2014


This is an automated email from the git hooks/post-receive script.

intrigeri pushed a commit to annotated tag 0.02
in repository libmoosex-lazyrequire-perl.

commit 0aadd3a529184a98d07a1b6f238b88f40bf5504a
Author: Florian Ragwitz <rafl at debian.org>
Date:   Mon Aug 17 11:09:14 2009 +0200

    Rename lazy_require to lazy_required.
---
 lib/MooseX/LazyRequire.pm                               | 14 +++++++-------
 .../LazyRequire/Meta/Attribute/Trait/LazyRequire.pm     | 17 ++++++++++++++---
 t/basic.t                                               |  8 ++++----
 3 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/lib/MooseX/LazyRequire.pm b/lib/MooseX/LazyRequire.pm
index d55138e..ba9faad 100644
--- a/lib/MooseX/LazyRequire.pm
+++ b/lib/MooseX/LazyRequire.pm
@@ -13,8 +13,8 @@ use namespace::autoclean;
     use MooseX::LazyRequire;
 
     has foo => (
-        is           => 'ro',
-        lazy_require => 1,
+        is            => 'ro',
+        lazy_required => 1,
     );
 
     has bar => (
@@ -31,7 +31,7 @@ use namespace::autoclean;
 
 =head1 DESCRIPTION
 
-This module adds a C<lazy_require> option to Moose attribute declarations.
+This module adds a C<lazy_required> 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
@@ -41,13 +41,13 @@ parameter or through a writer method.
 
 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
+C<lazy_required> in role attributes, you'll have to apply the attribute trait
 yourself:
 
     has foo => (
-        traits       => ['LazyRequire'],
-        is           => 'ro',
-        lazy_require => 1,
+        traits        => ['LazyRequire'],
+        is            => 'ro',
+        lazy_required => 1,
     );
 
 =cut
diff --git a/lib/MooseX/LazyRequire/Meta/Attribute/Trait/LazyRequire.pm b/lib/MooseX/LazyRequire/Meta/Attribute/Trait/LazyRequire.pm
index 2ff57ac..23d2c5b 100644
--- a/lib/MooseX/LazyRequire/Meta/Attribute/Trait/LazyRequire.pm
+++ b/lib/MooseX/LazyRequire/Meta/Attribute/Trait/LazyRequire.pm
@@ -1,22 +1,33 @@
 package MooseX::LazyRequire::Meta::Attribute::Trait::LazyRequire;
 
 use Moose::Role;
+use Carp qw/cluck/;
 use MooseX::Types::Moose qw/Bool/;
 use namespace::autoclean;
 
-has lazy_require => (
+has lazy_required => (
     is       => 'ro',
     isa      => Bool,
     required => 1,
     default  => 0,
 );
 
+has lazy_require => (
+    is       => 'bare',
+);
+
 after _process_options => sub {
     my ($class, $name, $options) = @_;
-    return unless $options->{lazy_require};
+
+    if (exists $options->{lazy_require}) {
+        cluck "deprecated option 'lazy_require' used. use 'lazy_required' instead.";
+        $options->{lazy_required} = delete $options->{lazy_require};
+    }
+
+    return unless $options->{lazy_required};
 
     Moose->throw_error(
-        "You may not use both a builder or a default and lazy_require for one attribute ($name)",
+        "You may not use both a builder or a default and lazy_required for one attribute ($name)",
         data => $options,
     ) if $options->{builder};
 
diff --git a/t/basic.t b/t/basic.t
index a29ca5d..86c2cbe 100644
--- a/t/basic.t
+++ b/t/basic.t
@@ -9,8 +9,8 @@ use Test::Exception;
     use MooseX::LazyRequire;
 
     has bar => (
-        is           => 'ro',
-        lazy_require => 1,
+        is            => 'ro',
+        lazy_required => 1,
     );
 
     has baz => (
@@ -47,8 +47,8 @@ throws_ok(sub {
     use MooseX::LazyRequire;
 
     has foo => (
-        is           => 'rw',
-        lazy_require => 1,
+        is            => 'rw',
+        lazy_required => 1,
     );
 
     has baz => (

-- 
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