| 1 | package Parse::FieldPath::Role; | ||||||||||||||||||||
| 2 | { | ||||||||||||||||||||
| 3 | 1 | $Parse::FieldPath::Role::VERSION = '0.005'; | |||||||||||||||||||
| 4 | } | ||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 1 | ▶ | use Moose::Role; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 1 | ▶ | use Parse::FieldPath; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 3 | ▶ | sub all_fields { | ||||||||||||||||||
|
Subroutine
all_fields: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 10 | 3 | my ($self) = @_; | |||||||||||||||||||
| 11 | 15 | return [ grep { defined } | |||||||||||||||||||
| 12 | 3 | ▶ | map { $_->accessor || $_->reader } $self->meta->get_all_attributes ]; | ||||||||||||||||||
|
Condition100%3/3
$_->accessor || $_->reader
MC/DC100%2/2
$_->accessor || $_->reader
$_->accessor
$_->reader
Truth table100%3/3
A || B
A= $_->accessorB= $_->reader
| |||||||||||||||||||||
| 13 | } | ||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 2 | ▶ | sub extract_fields { | ||||||||||||||||||
|
Subroutine
extract_fields: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 16 | 2 | return Parse::FieldPath::extract_fields(@_); | |||||||||||||||||||
| 17 | } | ||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | 1 | 1; | |||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | =pod | ||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | =head1 NAME | ||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | Parse::FieldPath::Role | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | =head1 ABSTRACT | ||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | Moose role to provide an C<extract_fields> method. | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | =head1 SYNOPSIS | ||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | package Boris; | ||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | use Moose; | ||||||||||||||||||||
| 36 | with 'Parse::FieldPath::Role'; | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | has plan => ( is => 'rw' ); | ||||||||||||||||||||
| 39 | has tnt => ( is => 'rw' ); | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | # Meanwhile.. | ||||||||||||||||||||
| 42 | my $boris = Boris->new(plan => 'a very evil plan', tnt => 'lots'); | ||||||||||||||||||||
| 43 | $boris->extract_fields(""); # returns: { | ||||||||||||||||||||
| 44 | plan => 'a very evil plan', | ||||||||||||||||||||
| 45 | tnt => 'lots', | ||||||||||||||||||||
| 46 | } | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | =head1 PROVIDED METHODS | ||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | =over 4 | ||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | =item B<all_fields()> | ||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | Called by C<extract_fields()> to get a list of every available field for the | ||||||||||||||||||||
| 55 | object. This implementation return the name of every attribute reader method. | ||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | =item B<extract_fields($field_path)> | ||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | Calls C<extract_fields> from L<Parse::FieldPath> on the object. | ||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | =back | ||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | =cut | ||||||||||||||||||||