| 1 | # Build::Hopen::G::Entity - base class for hopen's data model | ||||||||||||||
| 2 | package Build::Hopen::G::Entity; | ||||||||||||||
| 3 | 9 | ▶ | use Build::Hopen; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 9 | ▶ | use Build::Hopen::Base; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | |||||||||||||||
| 6 | 9 | our $VERSION = '0.000008'; # TRIAL | |||||||||||||
| 7 | |||||||||||||||
| 8 | sub name; | ||||||||||||||
| 9 | |||||||||||||||
| 10 | 9 | ▶ | use Class::Tiny qw(name); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 11 | |||||||||||||||
| 12 | =head1 NAME | ||||||||||||||
| 13 | |||||||||||||||
| 14 | Build::Hopen::G::Entity - The base class for all hopen nodes and edges | ||||||||||||||
| 15 | |||||||||||||||
| 16 | =head1 SYNOPSIS | ||||||||||||||
| 17 | |||||||||||||||
| 18 | hopen creates and manages a graph of entities: nodes and edges. This class | ||||||||||||||
| 19 | holds common information. | ||||||||||||||
| 20 | |||||||||||||||
| 21 | =head1 MEMBERS | ||||||||||||||
| 22 | |||||||||||||||
| 23 | =head2 name | ||||||||||||||
| 24 | |||||||||||||||
| 25 | The name of this entity. The name is for human consumption and is not used by | ||||||||||||||
| 26 | hopen to make any decisions. However, node names starting with an underscore | ||||||||||||||
| 27 | are reserved for hopen's internal use. | ||||||||||||||
| 28 | |||||||||||||||
| 29 | The name C<'0'> (a single digit zero) is forbidden (since it's falsy). | ||||||||||||||
| 30 | |||||||||||||||
| 31 | =cut | ||||||||||||||
| 32 | |||||||||||||||
| 33 | =head1 FUNCTIONS | ||||||||||||||
| 34 | |||||||||||||||
| 35 | =head2 name | ||||||||||||||
| 36 | |||||||||||||||
| 37 | A custom accessor for name. If no name has been stored, return the stringifed | ||||||||||||||
| 38 | version of the entity. That way every entity always has a name. | ||||||||||||||
| 39 | |||||||||||||||
| 40 | =cut | ||||||||||||||
| 41 | |||||||||||||||
| 42 | 28 | ▶ | sub name { | ||||||||||||
|
Subroutine
name: called CC=4 SCAR=14.6
Pod
documented
| |||||||||||||||
| 43 | 28 | ▶ | my $self = shift or croak 'Need an instance'; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 44 | 28 | ▶ | if (@_) { # Setter | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 45 | 7 | return $self->{name} = shift; | |||||||||||||
| 46 | } elsif ( exists $self->{name} ) { # Getter | ||||||||||||||
| 47 | 21 | return $self->{name}; | |||||||||||||
| 48 | } else { # Default | ||||||||||||||
| 49 | 0 | return "$self"; | |||||||||||||
| 50 | } | ||||||||||||||
| 51 | } #name() | ||||||||||||||
| 52 | |||||||||||||||
| 53 | =head2 has_custom_name | ||||||||||||||
| 54 | |||||||||||||||
| 55 | Returns truthy if a name has been set using L</name>. | ||||||||||||||
| 56 | |||||||||||||||
| 57 | =cut | ||||||||||||||
| 58 | |||||||||||||||
| 59 | 2 | ▶ | sub has_custom_name { !!(shift)->{name} } | ||||||||||||
|
Subroutine
has_custom_name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 60 | |||||||||||||||
| 61 | 9 | 1; | |||||||||||||
| 62 | __END__ | ||||||||||||||