c6659508c3327e738c4f3bba9c16511818d28a95
[gitmo/MooseX-Getopt.git] / lib / MooseX / Getopt / Meta / Attribute / NoGetopt.pm
1 package MooseX::Getopt::Meta::Attribute::NoGetopt;
2 # ABSTRACT: Optional meta attribute for ignoring params
3
4 use Moose;
5
6 extends 'Moose::Meta::Attribute'; # << Moose extending Moose :)
7    with 'MooseX::Getopt::Meta::Attribute::Trait::NoGetopt';
8
9 no Moose;
10
11 # register this as a metaclass alias ...
12 package # stop confusing PAUSE
13     Moose::Meta::Attribute::Custom::NoGetopt;
14 sub register_implementation { 'MooseX::Getopt::Meta::Attribute::NoGetopt' }
15
16 1;
17
18 =head1 SYNOPSIS
19
20   package App;
21   use Moose;
22
23   with 'MooseX::Getopt';
24
25   has 'data' => (
26       metaclass => 'NoGetopt',  # do not attempt to capture this param
27       is        => 'ro',
28       isa       => 'Str',
29       default   => 'file.dat',
30   );
31
32 =head1 DESCRIPTION
33
34 This is a custom attribute metaclass which can be used to specify
35 that a specific attribute should B<not> be processed by
36 C<MooseX::Getopt>. All you need to do is specify the C<NoGetopt>
37 metaclass.
38
39   has 'foo' => (metaclass => 'MooseX::Getopt::Meta::Attribute::NoGetopt', ... );
40
41 =head2 Use 'traits' instead of 'metaclass'
42
43 You should rarely need to explicitly set the attribute metaclass. It is much
44 preferred to simply provide a trait (a role applied to the attribute
45 metaclass), which allows other code to futher modify the attribute by applying
46 additional roles.
47
48 Therefore, you should first try to do this:
49
50   has 'foo' => (traits => ['NoGetopt', ...], ...);
51
52 =head2 Custom Metaclass alias
53
54 This now takes advantage of the Moose 0.19 feature to support
55 custom attribute metaclass. This means you can also
56 use this as the B<NoGetopt> alias, like so:
57
58   has 'foo' => (metaclass => 'NoGetopt', cmd_flag => 'f');
59
60 =cut