blib/lib/Bio/Community/Role/Locked.pm

filter: Statementstmt 100% 25 / 25 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod n/a totaltotal 94.5% 35 / 37 CC 3 SCAR 3.4
CC
3
Cov
93%
lock
2.0
unlock
2.0
BEGIN
1.0
CRAP 1.4
« blib/lib/Bio/Community/Role/PRNG.pm ↑ Summary blib/lib/Bio/Community/Role/Sequenced.pm »
1 # BioPerl module for Bio::Community::Role::Locked
2 #
3 # Please direct questions and support issues to <bioperl-l@bioperl.org>
4 #
5 # Copyright 2011-2014 Florent Angly <florent.angly@gmail.com>
6 #
7 # You may distribute this module under the same terms as perl itself
8  
9  
10 =head1 NAME
11  
12 Bio::Community::Role::Locked - Role for objects that can be locked (made read-only)
13  
14 =head1 SYNOPSIS
15  
16 package My::Package;
17  
18 use Moose;
19 with 'Bio::Community::Role::Locked';
20  
21 # Use the lock() and unlock() methods as needed
22 # ...
23  
24 1;
25  
26 =head1 DESCRIPTION
27  
28 This role provides the capability to make objects of the class that consumes this
29 role read-only. The lock() method can be invoked to make an object read-only,
30 while unlock() restores the read/write properties of the object. If you try to
31 call a method to modify an object that is locked or otherwise attempt to change
32 its hash, you will get an error similar to this:
33  
34 Modification of a read-only value attempted at accessor Bio::Community::Member::foo
35  
36 =head1 AUTHOR
37  
38 Florent Angly L<florent.angly@gmail.com>
39  
40 =head1 SUPPORT AND BUGS
41  
42 User feedback is an integral part of the evolution of this and other Bioperl
43 modules. Please direct usage questions or support issues to the mailing list,
44 L<bioperl-l@bioperl.org>, rather than to the module maintainer directly. Many
45 experienced and reponsive experts will be able look at the problem and quickly
46 address it. Please include a thorough description of the problem with code and
47 data examples if at all possible.
48  
49 If you have found a bug, please report it on the BioPerl bug tracking system
50 to help us keep track the bugs and their resolution:
51 L<https://redmine.open-bio.org/projects/bioperl/>
52  
53 =head1 COPYRIGHT
54  
55 Copyright 2011-2014 by Florent Angly <florent.angly@gmail.com>
56  
57 This library is free software; you can redistribute it and/or modify
58 it under the same terms as Perl itself, either Perl version 5.10.1 or,
59 at your option, any later version of Perl 5 you may have available.
60  
61 =head1 APPENDIX
62  
63 The rest of the documentation details each of the object
64 methods. Internal methods are usually preceded with a _
65  
66 =cut
67  
68  
69 package Bio::Community::Role::Locked;
70  
71 1 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
72 1 ▶use Method::Signatures;
Subroutine BEGIN: called CC=1 SCAR=0.0
73 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
74 1 ▶use Hash::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
75  
76  
77 =head2 lock
78  
79 Usage : $member->lock();
80 Function: Lock the object, making it read-only.
81 Args : None
82 Returns : 1 for success
83  
84 =cut
85  
86 1 ▶method lock () {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine lock: called CC=2 SCAR=7.0
Branch: 1 branch
BranchTrueFalseTotal
if scalar @_ > 0 0 1 1
87 #Hash::Util::lock_hash_recurse(%$self);
88 1 Hash::Util::lock_hash(%$self);
89 1 return 1;
90 }
91  
92  
93 =head2 unlock
94  
95 Usage : $member->unlock();
96 Function: Unlock the object, restoring its read and write properties.
97 Args : None
98 Returns : 1 for success
99  
100 =cut
101  
102 1 ▶method unlock () {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine unlock: called CC=2 SCAR=7.0
Branch: 1 branch
BranchTrueFalseTotal
if scalar @_ > 0 0 1 1
103 #Hash::Util::unlock_hash_recurse(%$self);
104 1 Hash::Util::unlock_hash(%$self);
105 1 return 1;
106 }
107  
108  
109 1 1;
« blib/lib/Bio/Community/Role/PRNG.pm ↑ Summary blib/lib/Bio/Community/Role/Sequenced.pm »