| 1 | package SPVM::Builder::Resource; | ||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||
| 3 | 367 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 4 | 369 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 5 | 369 | ▶ | use Config; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 6 | 369 | ▶ | use Carp 'confess'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 7 | 369 | ▶ | use File::Basename 'dirname'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||
| 9 | 369 | ▶ | use overload bool => sub {1}, '""' => sub { shift->to_string }, fallback => 1; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||
| 11 | # Fields | ||||||||||||||||||||||||||||||||||||||
| 12 | 673 | ▶ | sub class_name { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
class_name: called CC=2 SCAR=10.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 13 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
class_name: not called CC=2 SCAR=10.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 14 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 15 | 0 | $self->{class_name} = $_[0]; | |||||||||||||||||||||||||||||||||||||
| 16 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||||||||||||
| 18 | else { | ||||||||||||||||||||||||||||||||||||||
| 19 | 0 | return $self->{class_name}; | |||||||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||
| 23 | 986 | ▶ | sub config { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
config: called CC=2 SCAR=9.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
config: not called CC=2 SCAR=9.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 26 | 0 | $self->{config} = $_[0]; | |||||||||||||||||||||||||||||||||||||
| 27 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||
| 29 | else { | ||||||||||||||||||||||||||||||||||||||
| 30 | 0 | return $self->{config}; | |||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||
| 34 | # Methods | ||||||||||||||||||||||||||||||||||||||
| 35 | 605 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||
| 38 | 0 | my $self = {@_}; | |||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | bless $self, ref $class || $class; | ||||||||||||||||||||||||||||||||||||
|
Condition16%1/6
ref $class || $class
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
Truth table0%0/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||
| 42 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||
| 45 | 424 | ▶ | sub to_string { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
to_string: called CC=1 SCAR=1.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
to_string: not called CC=1 SCAR=1.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||
| 48 | 0 | return $self->class_name; | |||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||
| 51 | 367 | 1; | |||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||
| 53 | =head1 Name | ||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||
| 55 | SPVM::Builder::Resource - Resource | ||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||
| 57 | =head1 Description | ||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||
| 59 | The SPVM::Builder::Resource class has methods to manipulate L<resources|SPVM::Document::Resource>. | ||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||
| 61 | =head1 Usage | ||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||
| 63 | my $resource = SPVM::Builder::Resource->new( | ||||||||||||||||||||||||||||||||||||||
| 64 | class_name => 'Resource::Zlib', | ||||||||||||||||||||||||||||||||||||||
| 65 | ); | ||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||
| 67 | =head1 Details | ||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||
| 69 | See L<SPVM::Document::Resource> about creating and using resources. | ||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||
| 71 | =head1 Fields | ||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||
| 73 | =head2 class_name | ||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||
| 75 | my $class_name = $resource->class_name; | ||||||||||||||||||||||||||||||||||||||
| 76 | $resource->class_name($class_name); | ||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||
| 78 | Gets and sets the C<class_name> field, the class name of this resource. | ||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||
| 80 | =head2 config | ||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||
| 82 | my $config = $resource->config; | ||||||||||||||||||||||||||||||||||||||
| 83 | $resource->config($config); | ||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||
| 85 | Gets and sets the C<config> field, an L<SPVM::Builder::Config> object. | ||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||
| 87 | =head1 Class Methods | ||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||
| 89 | =head2 new | ||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||
| 91 | my $resource = SPVM::Builder::Resource->new(%fields); | ||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||
| 93 | Creates a new L<SPVM::Builder::Resource> object with L</"Fields">. | ||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||
| 95 | Field Default Values: | ||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||
| 97 | =over 2 | ||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||
| 99 | =item * L</"class_name"> | ||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||
| 101 | undef | ||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||
| 103 | =item * L</"config"> | ||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||
| 105 | undef | ||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||
| 107 | =back | ||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||
| 109 | =head1 Instance Methods | ||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||
| 111 | =head2 to_string | ||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||
| 113 | my $string = $resource->to_string; | ||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||
| 115 | Returns L</"class_name"> field. | ||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||
| 117 | =head1 Operators | ||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||
| 119 | Overloads the following operators. | ||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||
| 121 | =head2 bool | ||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||
| 123 | my $bool = !!$resource; | ||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||
| 125 | Always true. | ||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||
| 127 | =head2 stringify | ||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||
| 129 | my $class_name = "$resource"; | ||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||
| 131 | The alias for L</"to_string"> method. | ||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||
| 133 | =head1 Copyright & License | ||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||
| 135 | Copyright (c) 2023 Yuki Kimoto | ||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||
| 137 | MIT License | ||||||||||||||||||||||||||||||||||||||