| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Data::Object::Role::Immutable; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
222602
|
use 5.014; |
|
|
1
|
|
|
|
|
74
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
7
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
21
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
29
|
|
|
7
|
1
|
|
|
1
|
|
6
|
use routines; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
5
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
1474
|
use Moo::Role; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
7
|
|
|
10
|
1
|
|
|
1
|
|
838
|
use Readonly; |
|
|
1
|
|
|
|
|
3354
|
|
|
|
1
|
|
|
|
|
150
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '2.01'; # VERSION |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# METHODS |
|
15
|
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
1
|
27486
|
method immutable() { |
|
|
1
|
|
|
|
|
3
|
|
|
17
|
1
|
50
|
|
|
|
6
|
if (UNIVERSAL::isa($self, 'HASH')) { |
|
18
|
1
|
|
|
|
|
7
|
Readonly::Hash(%$self, %$self); |
|
19
|
|
|
|
|
|
|
} |
|
20
|
1
|
50
|
|
|
|
36
|
if (UNIVERSAL::isa($self, 'ARRAY')) { |
|
21
|
0
|
|
|
|
|
0
|
Readonly::Array(@$self, @$self); |
|
22
|
|
|
|
|
|
|
} |
|
23
|
1
|
50
|
|
|
|
4
|
if (UNIVERSAL::isa($self, 'SCALAR')) { |
|
24
|
0
|
|
|
|
|
0
|
Readonly::Scalar($$self, $$self); |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
1
|
|
|
|
|
8
|
return $self; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
1; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=encoding utf8 |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 NAME |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Data::Object::Role::Immutable |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=cut |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 ABSTRACT |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Immutable Role for Perl 5 |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
package Example; |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
use Moo; |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
with 'Data::Object::Role::Immutable'; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
package main; |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
my $example = Example->new; |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
This package provides a mechanism for making any derived object immutable. |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 METHODS |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
This package implements the following methods: |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 immutable |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
immutable() : Object |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
The immutable method returns the invocant as an immutable object, and will |
|
77
|
|
|
|
|
|
|
throw an error if an attempt is made to modify the underlying value. |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=over 4 |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=item immutable example #1 |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# given: synopsis |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
$example->immutable; |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=back |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 AUTHOR |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Al Newkirk, C |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 LICENSE |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Copyright (C) 2011-2019, Al Newkirk, et al. |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under the terms |
|
100
|
|
|
|
|
|
|
of the The Apache License, Version 2.0, as elucidated in the L<"license |
|
101
|
|
|
|
|
|
|
file"|https://github.com/iamalnewkirk/data-object-role-immutable/blob/master/LICENSE>. |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 PROJECT |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
L |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
L |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
L |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
L |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
L |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
L |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=cut |