This file is indexed.

/usr/share/perl5/MouseX/NativeTraits.pm is in libmousex-nativetraits-perl 1.09-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
package MouseX::NativeTraits;
use 5.006_002;
use Mouse::Role;

our $VERSION = '1.09';

requires qw(method_provider_class helper_type);

#has default         => (
#    is       => 'bare', # don't create new methods
#    required => 1,
#);
has type_constraint => (
    is       => 'bare', # don't create new methods
    required => 1,
);

has method_provider => (
    is  => 'ro',
    isa => 'Object',

    builder => '_build_method_provider',
);

sub _build_method_provider{
    my($self) = @_;
    my $mpc = $self->method_provider_class;
    Mouse::Util::load_class($mpc);
    return $mpc->new(attr => $self);
}

before _process_options => sub {
    my ( $self, $name, $options ) = @_;

    my $type = $self->helper_type;

    $options->{isa} = $type
        if !exists $options->{isa};

    my $isa = Mouse::Util::TypeConstraints::find_or_create_isa_type_constraint(
        $options->{isa} );

    ( $isa->is_a_type_of($type) )
        || $self->throw_error(
        "The type constraint for $name must be a subtype of $type but it's a $isa");

    $options->{default} = $self->_default_default
        if !exists $options->{default} && $self->can('_default_default');
};

around _canonicalize_handles => sub {
    my($next, $self) = @_;
    my $handles_ref = $self->handles;
    if( ref($handles_ref) ne 'HASH' ) {
        $self->throw_error(
            "The 'handles' option must be a HASH reference, not $handles_ref");
    }

    my $provider = $self->method_provider;

    my %handles;
    while(my($name, $to) = each %{$handles_ref}){
        $to = [$to] if !ref $to;
        $provider->has_generator($to->[0])
            or $self->throw_error("$to->[0] is an unsupported method type");
        $handles{$name} = $to;
    }

    return %handles;
};

around _make_delegation_method => sub {
    my( $next, $self, $handle_name, $method_to_call) = @_;
    return $self->method_provider->generate($handle_name, $method_to_call);
};

no Mouse::Role;
1;
__END__

=head1 NAME

MouseX::NativeTraits - Extend your attribute interfaces for Mouse

=head1 VERSION

This document describes MouseX::NativeTraits version 1.09.

=head1 SYNOPSIS

    package MyClass;
    use Mouse;

    has mapping => (
        traits    => ['Hash'],
        is        => 'rw',
        isa       => 'HashRef[Str]',
        default   => sub { +{} },
        handles   => {
            exists_in_mapping => 'exists',
            ids_in_mapping    => 'keys',
            get_mapping       => 'get',
            set_mapping       => 'set',
            set_quantity      => [ set => 'quantity' ],
        },
    );

=head1 DESCRIPTION

While L<Mouse> attributes provide a way to name your accessors, readers,
writers, clearers and predicates, MouseX::NativeTraits provides commonly
used attribute helper methods for more specific types of data.

As seen in the L</SYNOPSIS>, you specify the data structure via the
C<traits> parameter. These traits will be loaded automatically, so
you need not load MouseX::NativeTraits explicitly.

This extension is compatible with Moose native traits, although it
is not a part of Mouse core.

=head1 PARAMETERS

=head2 handles

This is like C<handles> in L<Mouse/has>, but only HASH references are
allowed.  Keys are method names that you want installed locally, and values are
methods from the method providers (below).  Currying with delegated methods
works normally for C<< handles >>.

=head1 NATIVE TRAITS

=head2 Array

Common methods for array references.

    has 'queue' => (
       traits     => ['Array'],
       is         => 'ro',
       isa        => 'ArrayRef[Str]',
       default    => sub { [] },
       handles    => {
           add_item  => 'push',
           next_item => 'shift',
       }
    );

See L<MouseX::NativeTraits::ArrayRef>.

=head2 Hash

Common methods for hash references.

    has 'options' => (
        traits    => ['Hash'],
        is        => 'ro',
        isa       => 'HashRef[Str]',
        default   => sub { {} },
        handles   => {
            set_option => 'set',
            get_option => 'get',
            has_option => 'exists',
        }
    );

See L<MouseX::NativeTraits::HashRef>.

=head2 Code

Common methods for code references.

    has 'callback' => (
       traits     => ['Code'],
       is         => 'ro',
       isa        => 'CodeRef',
       default    => sub { sub { 'called' } },
       handles    => {
           call => 'execute',
       }
    );

See L<MouseX::NativeTraits::CodeRef>.

=head2 Bool

Common methods for boolean values.

    has 'is_lit' => (
        traits    => ['Bool'],
        is        => 'rw',
        isa       => 'Bool',
        default   => 0,
        handles   => {
            illuminate  => 'set',
            darken      => 'unset',
            flip_switch => 'toggle',
            is_dark     => 'not',
        }
    );

See L<MouseX::NativeTraits::Bool>.

=head2 String

Common methods for string operations.

    has text => (
        traits    => ['String'],
        is        => 'rw',
        isa       => 'Str',
        default   => q{},
        handles   => {
            add_text     => 'append',
            replace_text => 'replace', # or replace_globally
        }
    );

See L<MouseX::NativeTraits::Str>.

=head2 Number

Common numerical operations.

    has value => (
        traits    => ['Number'],
        is        => 'ro',
        isa       => 'Int',
        default   => 5,
        handles   => {
            set => 'set',
            add => 'add',
            sub => 'sub',
            mul => 'mul',
            div => 'div',
            mod => 'mod',
            abs => 'abs',
        }
    );

See L<MouseX::NativeTraits::Num>.

=head2 Counter

Methods for incrementing and decrementing a counter attribute.

    has counter => (
        traits    => ['Counter'],
        is        => 'ro',
        isa       => 'Num',
        default   => 0,
        handles   => {
            inc_counter   => 'inc',
            dec_counter   => 'dec',
            reset_counter => 'reset',
        }
    );

See L<MouseX::NativeTraits::Counter>.

=head1 DEPENDENCIES

Perl 5.6.2 or later.

=head1 BUGS

All complex software has bugs lurking in it, and this module is no
exception. If you find a bug please either email me, or add the bug
to cpan-RT.

=head1 SEE ALSO

L<Mouse>

L<MouseX::AttributeHelpers>

L<Moose>

L<Moose::Meta::Attribute::Native>

L<MooseX::AttributeHelpers>

=head1 AUTHORS

Goro Fuji (gfx) E<lt>gfuji(at)cpan.orgE<gt>

This module is based on Moose native traits written by Stevan Little and others.

=head1 LICENSE AND COPYRIGHT

Copyright (c) 2010, Goro Fuji (gfx), mostly based on Moose, which is (c)
Infinity Interactive, Inc (L<http://www.iinteractive.com>).

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself. See L<perlartistic> for details.

=cut