| 1 | # Bio/RNA/BarMap/Mapping/MinMappingEntry.pm | ||
| 2 | |||
| 3 | package Bio::RNA::BarMap::Mapping::MinMappingEntry; | ||
| 4 | 5 | our $VERSION = '0.04'; | |
| 5 | |||
| 6 | 5 | ▶ | use 5.012; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 5 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 5 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | 5 | ▶ | use namespace::autoclean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | |||
| 12 | 5 | ▶ | use Scalar::Util qw( weaken ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | |||
| 14 | 5 | ▶ | use Bio::RNA::BarMap::Mapping::Type; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | 5 | ▶ | use Bio::RNA::BarMap::Mapping::Set; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 16 | |||
| 17 | |||
| 18 | 5 | has 'index' => (is => 'ro', required => 1); | |
| 19 | |||
| 20 | 5 | has 'to_type' => ( | |
| 21 | is => 'rw', | ||
| 22 | isa => 'Bio::RNA::BarMap::Mapping::Type', | ||
| 23 | ); | ||
| 24 | |||
| 25 | # Ensure object is cleaned after use => use weak refs | ||
| 26 | has '_from' => ( | ||
| 27 | is => 'ro', | ||
| 28 | init_arg => undef, # use add_from() method to add elements | ||
| 29 | 7088 | ▶ | default => sub { Bio::RNA::BarMap::Mapping::Set->new }, |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 30 | 5 | ); | |
| 31 | |||
| 32 | 5 | has 'to' => ( | |
| 33 | is => 'rw', | ||
| 34 | weak_ref => 1, | ||
| 35 | predicate => 'has_to', | ||
| 36 | isa => __PACKAGE__, # another entry | ||
| 37 | ); | ||
| 38 | |||
| 39 | # Always use this method to add 'from' minima. This ensures the refs | ||
| 40 | # are weakened and no memory leaks arise. | ||
| 41 | 6732 | ▶ | sub add_from { |
|
Subroutine
add_from: called CC=2 SCAR=6.9
Pod
documented
| |||
| 42 | 6732 | my ($self, @from) = @_; | |
| 43 | 6732 | weaken $_ foreach @from; # turn into weak references | |
| 44 | 6732 | $self->_from->insert(@from); | |
| 45 | } | ||
| 46 | |||
| 47 | 0 | ▶ | sub get_from { |
|
Subroutine
get_from: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 48 | 0 | my ($self) = @_; | |
| 49 | 0 | my @from = $self->_from->elements; | |
| 50 | 0 | return @from; | |
| 51 | } | ||
| 52 | |||
| 53 | 5 | __PACKAGE__->meta->make_immutable; | |
| 54 | |||
| 55 | 5 | 1; # End of Bio::RNA::BarMap::Mapping::MinMappingEntry | |
| 56 | |||
| 57 | |||
| 58 | __END__ | ||