File: TiedRO.pm

package info (click to toggle)
liblist-objects-withutils-perl 2.028003-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,292 kB
  • sloc: perl: 1,957; makefile: 17; sh: 6
file content (32 lines) | stat: -rw-r--r-- 676 bytes parent folder | download | duplicates (4)
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
package List::Objects::WithUtils::Role::Array::TiedRO;
$List::Objects::WithUtils::Role::Array::TiedRO::VERSION = '2.028003';
=for Pod::Coverage *EVERYTHING*

=cut

use strictures 2;
use Carp ();

# This role can be applied to the objects backing tied arrays
# after construction time in order to swap a mutable tied array
# for an immutable implementation;
# Array::Immutable::Typed::immarray_of does this in order to retain
# normal tied type array behavior until construction is complete.

use Role::Tiny;

around $_ => sub {
  Carp::croak "Attempted to modify a read-only value"
} for qw/
  STORE
  STORESIZE
  CLEAR
  PUSH
  POP
  SHIFT
  SPLICE
  UNSHIFT
  EXTEND
/;

1;