line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooseX::ClosedHash; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
271985
|
use 5.008; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
54
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
BEGIN { |
6
|
1
|
|
|
1
|
|
2
|
$MooseX::ClosedHash::AUTHORITY = 'cpan:TOBYINK'; |
7
|
1
|
|
|
|
|
16
|
$MooseX::ClosedHash::VERSION = '0.002'; |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
2181
|
use Moose (); |
|
1
|
|
|
|
|
367116
|
|
|
1
|
|
|
|
|
46
|
|
11
|
1
|
|
|
1
|
|
10
|
use Moose::Exporter; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
12
|
1
|
|
|
1
|
|
77
|
use Moose::Util::MetaRole; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
13
|
1
|
|
|
1
|
|
765
|
use MooseX::ClosedHash::Meta::Instance (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
14
|
1
|
|
|
1
|
|
689
|
use MooseX::ClosedHash::Meta::Class (); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
125
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Moose::Exporter->setup_import_methods( |
17
|
|
|
|
|
|
|
also => [qw( Moose )], |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub init_meta |
21
|
|
|
|
|
|
|
{ |
22
|
2
|
|
|
2
|
0
|
2058
|
shift; |
23
|
2
|
|
|
|
|
6
|
my %p = @_; |
24
|
2
|
|
|
|
|
12
|
Moose->init_meta(%p); |
25
|
2
|
|
|
|
|
10372
|
Moose::Util::MetaRole::apply_metaroles( |
26
|
|
|
|
|
|
|
for => $p{for_class}, |
27
|
|
|
|
|
|
|
class_metaroles => { |
28
|
|
|
|
|
|
|
instance => [qw( MooseX::ClosedHash::Meta::Instance )], |
29
|
|
|
|
|
|
|
class => [qw( MooseX::ClosedHash::Meta::Class )], |
30
|
|
|
|
|
|
|
}, |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
[qw( Yeah baby yeah )]; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
__END__ |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=pod |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=encoding utf-8 |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 NAME |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
MooseX::ClosedHash - blessed coderefs (closing over a hash) with Moose |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 SYNOPSIS |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
use v5.14; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
package Person { |
51
|
|
|
|
|
|
|
use MooseX::ClosedHash; |
52
|
|
|
|
|
|
|
has name => (is => "rw"); |
53
|
|
|
|
|
|
|
has age => (is => "rw"); |
54
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my $bob = Person->new(name => "Bob", age => 42); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
say $bob->name, " is ", $bob->age, " years old."; |
60
|
|
|
|
|
|
|
say $bob->dump; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 DESCRIPTION |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
L<MooseX::ClosedHash> is a Moose module that lets you store your object's |
65
|
|
|
|
|
|
|
attributes in a hash, closed over by a blessed coderef. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Why? I have no idea why you'd want to do this. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
It provides a modicum of privacy I suppose. Privacy that is easily violated, |
70
|
|
|
|
|
|
|
but that you're unlikely to accidentally violate. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 BUGS |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Please report any bugs to |
75
|
|
|
|
|
|
|
L<http://rt.cpan.org/Dist/Display.html?Queue=MooseX-ClosedHash>. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 SEE ALSO |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
L<http://www.perlmonks.org/?node_id=1039960>. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
L<MooseX::ArrayRef>, L<MooseX::GlobRef>, L<MooseX::InsideOut>, etc. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 AUTHOR |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Toby Inkster E<lt>tobyink@cpan.orgE<gt>. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENCE |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
This software is copyright (c) 2013 by Toby Inkster. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
92
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTIES |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED |
97
|
|
|
|
|
|
|
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
98
|
|
|
|
|
|
|
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
99
|
|
|
|
|
|
|
|