Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

v0.011

  • Loading branch information...
commit 07ed020ab32a2580e409f5d801b2c5426301c1bc 1 parent 3be7c9e
Chris Weyl authored
Showing with 36 additions and 1 deletion.
  1. +3 −0  Changes
  2. +33 −1 README.pod
3  Changes
View
@@ -2,6 +2,9 @@ Revision history for Reindeer
{{$NEXT}}
+0.011 2012-04-26 23:26:57 America/Los_Angeles
+- add ENV as an optional attribute trait
+
0.010 2012-04-25 10:34:11 America/Los_Angeles
- bump IxHash req to 0.003; this is the first version that omits coercion from
hashrefs.
34 README.pod
View
@@ -8,7 +8,7 @@ Reindeer - Moose with more antlers
=head1 VERSION
-This document describes version 0.010 of Reindeer - released April 25, 2012 as part of Reindeer.
+This document describes version 0.011 of Reindeer - released April 26, 2012 as part of Reindeer.
=head1 SYNOPSIS
@@ -236,6 +236,38 @@ defined).
See L<MooseX::AutoDestruct> for more information.
+=head2 ENV
+
+This is a Moose attribute trait that you use when you want the default value
+for an attribute to be populated from the %ENV hash. So, for example if you
+have set the environment variable USERNAME to 'John' you can do:
+
+ package MyApp::MyClass;
+
+ use Moose;
+ use MooseX::Attribute::ENV;
+
+ has 'username' => (is=>'ro', traits=>['ENV']);
+
+ package main;
+
+ my $myclass = MyApp::MyClass->new();
+
+ print $myclass->username; # STDOUT => 'John';
+
+This is basically similar functionality to something like:
+
+ has 'attr' => (
+ is=>'ro',
+ default=> sub {
+ $ENV{uc 'attr'};
+ },
+ );
+
+If the named key isn't found in %ENV, then defaults will execute as normal.
+
+See L<MooseX::Attribute::ENV> for more information.
+
=head2 MultiInitArg
has 'data' => (
Please sign in to comment.
Something went wrong with that request. Please try again.