| 1 | package Net::Gnats::Schema; | ||||||||||
| 2 | 40 | ▶ | use strictures; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 40 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 40 | $Net::Gnats::Schema::VERSION = '0.22'; | |||||||||
| 5 | } | ||||||||||
| 6 | 40 | ▶ | use vars qw($VERSION); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 40 | ▶ | use Net::Gnats::Command; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 40 | ▶ | use Net::Gnats::Field; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 40 | ▶ | use Net::Gnats::PR; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | |||||||||||
| 13 | 38 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||
| 14 | 38 | my ( $class, $session ) = @_; | |||||||||
| 15 | |||||||||||
| 16 | 38 | my $self = bless {}, $class; | |||||||||
| 17 | 38 | ▶ | $self->initialize($session) if defined $session; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 18 | 38 | return $self; | |||||||||
| 19 | } | ||||||||||
| 20 | |||||||||||
| 21 | =head2 initialize | ||||||||||
| 22 | |||||||||||
| 23 | Initializes, or re-initializes, the schema for this session. | ||||||||||
| 24 | |||||||||||
| 25 | =cut | ||||||||||
| 26 | |||||||||||
| 27 | 38 | ▶ | sub initialize { | ||||||||
|
Subroutine
initialize: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 28 | 38 | my ( $self, $session ) = @_; | |||||||||
| 29 | |||||||||||
| 30 | 38 | my $c_f = Net::Gnats::Command->list(subcommand => 'fieldnames'); | |||||||||
| 31 | 38 | my $fields = $session->issue($c_f)->response->as_list; | |||||||||
| 32 | |||||||||||
| 33 | 38 | my $c_fr = Net::Gnats::Command->list(subcommand => 'initialrequiredfields'); | |||||||||
| 34 | 38 | my $c_fi = Net::Gnats::Command->list(subcommand => 'initialinputfields'); | |||||||||
| 35 | |||||||||||
| 36 | 38 | $self->{initial} = $session->issue($c_fi)->response->as_list; | |||||||||
| 37 | 38 | $self->{required} = $session->issue($c_fr)->response->as_list; | |||||||||
| 38 | |||||||||||
| 39 | 38 | my $c_types = Net::Gnats::Command->ftyp(fields => $fields); | |||||||||
| 40 | 38 | my $c_descs = Net::Gnats::Command->fdsc(fields => $fields); | |||||||||
| 41 | 38 | my $c_deflt = Net::Gnats::Command->inputdefault(fields => $fields); | |||||||||
| 42 | 38 | my $c_flags = Net::Gnats::Command->fieldflags(fields => $fields); | |||||||||
| 43 | |||||||||||
| 44 | 38 | $session->issue($c_types); | |||||||||
| 45 | 38 | $session->issue($c_descs); | |||||||||
| 46 | 38 | $session->issue($c_deflt); | |||||||||
| 47 | 38 | $session->issue($c_flags); | |||||||||
| 48 | |||||||||||
| 49 | 38 | foreach my $fname (@{ $fields }) { | |||||||||
| 50 | 912 | my $f = Net::Gnats::Field->new; | |||||||||
| 51 | 912 | $f->name($fname); | |||||||||
| 52 | 912 | $f->description($c_descs->from($fname)); | |||||||||
| 53 | 912 | $f->type($c_types->from($fname)); | |||||||||
| 54 | 912 | $f->default($c_deflt->from($fname)); | |||||||||
| 55 | 912 | $f->flags($c_flags->from($fname)); | |||||||||
| 56 | 912 | $self->{fields}->{$fname} = $f; | |||||||||
| 57 | # $self->{db_meta}->{fields}->{$f}->{validators} = @{ $vldtr }[$i]; | ||||||||||
| 58 | } | ||||||||||
| 59 | } | ||||||||||
| 60 | |||||||||||
| 61 | |||||||||||
| 62 | =head2 field | ||||||||||
| 63 | |||||||||||
| 64 | Returns the field object for the named field. | ||||||||||
| 65 | |||||||||||
| 66 | =cut | ||||||||||
| 67 | |||||||||||
| 68 | 226 | ▶ | sub field { | ||||||||
|
Subroutine
field: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 69 | 226 | my ( $self, $name ) = @_; | |||||||||
| 70 | 226 | ▶ | return 0 if not defined $self->{fields}->{$name}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 71 | 136 | return $self->{fields}->{$name} | |||||||||
| 72 | } | ||||||||||
| 73 | |||||||||||
| 74 | =head2 fields | ||||||||||
| 75 | |||||||||||
| 76 | Returns an anonymous array of all fields for this PR Schema. | ||||||||||
| 77 | |||||||||||
| 78 | =cut | ||||||||||
| 79 | |||||||||||
| 80 | 198 | ▶ | sub fields { [ keys %{ shift->{fields} } ] } | ||||||||
|
Subroutine
fields: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 81 | |||||||||||
| 82 | =head2 initial | ||||||||||
| 83 | |||||||||||
| 84 | Returns an anonymous array of initial input fields for this PR Schema. | ||||||||||
| 85 | |||||||||||
| 86 | =cut | ||||||||||
| 87 | |||||||||||
| 88 | 0 | ▶ | sub initial { shift->{initial} } | ||||||||
|
Subroutine
initial: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 89 | |||||||||||
| 90 | =head2 required | ||||||||||
| 91 | |||||||||||
| 92 | Returns an anonymous array of required input fields for this PR Schema. | ||||||||||
| 93 | |||||||||||
| 94 | =cut | ||||||||||
| 95 | |||||||||||
| 96 | 0 | ▶ | sub required { shift->{required} } | ||||||||
|
Subroutine
required: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 97 | |||||||||||
| 98 | 0 | ▶ | sub new_pr { | ||||||||
|
Subroutine
new_pr: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 99 | 0 | my ($self) = @_; | |||||||||
| 100 | 0 | return Net::Gnats::PR->new(); | |||||||||
| 101 | } | ||||||||||
| 102 | |||||||||||
| 103 | 40 | 1; | |||||||||