initial checkin
[gitmo/MooseX-Attribute-ENV.git] / README
1 MooseX-Attribute-ENV
2
3 This is a L<Moose> attribute trait that you use when you want the default value
4 for an attribute to be populated from the %ENV hash.  So, for example if you
5 have set the environment variable MYAPP_MYCLASS_USERNAME = 'John' you can do:
6
7         package MyApp::MyClass;
8         
9         use Moose;
10         use MooseX::Attribute::ENV;
11         
12         has 'username' => (is=>'ro', traits=>['ENV']);
13         
14         package main;
15         
16         my $myclass = MyApp::MyClass->new();
17         
18         print $myclass->username; # STDOUT => 'John';
19
20 This is basically similar functionality to something like:
21
22         has 'attr' => (
23                 is=>'ro',
24                 default=> sub {
25                         $ENV{uc __PACKAGE_.'attr'};
26                 },
27         );
28         
29 but this module has a few other features that offer merit, as well as being a
30 simple enough attribute trait that I hope it can serve as a learning tool.
31
32 INSTALLATION
33
34 To install this module, run the following commands:
35
36         perl Makefile.PL
37         make
38         make test
39         make install
40
41 SUPPORT AND DOCUMENTATION
42
43 After installing, you can find documentation for this module with the
44 perldoc command.
45
46     perldoc MooseX-Attribute-ENV
47
48 You can also look for information at:
49
50     RT, CPAN's request tracker
51         http://rt.cpan.org/NoAuth/Bugs.html?Dist=MooseX-Attribute-ENV
52
53     AnnoCPAN, Annotated CPAN documentation
54         http://annocpan.org/dist/MooseX-Attribute-ENV
55
56     CPAN Ratings
57         http://cpanratings.perl.org/d/MooseX-Attribute-ENV
58
59     Search CPAN
60         http://search.cpan.org/dist/MooseX-Attribute-ENV
61
62
63 COPYRIGHT AND LICENCE
64
65 Copyright (C) 2008 John Napiorkowski
66
67 This program is free software; you can redistribute it and/or modify it
68 under the same terms as Perl itself.
69