LDAP/LDIF.pm

filter: Statementstmt 67.6% 23 / 34 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 5 / 10 Podpod 0.0% 0 / 6 totaltotal 50.0% 28 / 56 CC 5 SCAR 11.9
CC
5
Cov
58%
search
6.0
delete
6.0
save
6.0
CRAP 3.3
« LDAP/Role/Bindable.pm ↑ Summary LDAP/Command/Del/Ou.pm »
1 package App::LDAP::LDIF;
2  
3 7 ▶use Modern::Perl;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 7 ▶use Net::LDAP::Entry;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 7 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 7 with qw(
10 App::LDAP::Role
11 App::LDAP::Role::FromEntry
12 );
13  
14 7 has dn => (
15 is => "rw",
16 isa => "Str",
17 required => 1,
18 );
19  
20 0 ▶sub create {
Subroutine create: not called CC=1 SCAR=0.0
Pod undocumented
21  
22 }
23  
24 0 ▶sub search {
Subroutine search: not called CC=2 SCAR=17.9
Pod undocumented
25 0 my ($class, %options) = @_;
26  
27 0 my $search = ldap()->search(%options);
28  
29 0 ▶ if ($search->count) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search->count) { } 0 0 0
30 0 return $class->new( $search->entry(0) );
31 } else {
32 0 return undef;
33 }
34 }
35  
36 0 ▶sub update {
Subroutine update: not called CC=1 SCAR=0.0
Pod undocumented
37  
38 }
39  
40 0 ▶sub delete {
Subroutine delete: not called CC=2 SCAR=17.9
Pod undocumented
41 0 my ($self) = shift;
42  
43 0 my $msg = ldap()->delete($self->dn);
44  
45 0 ▶ die $msg->error if $msg->code;
Branch: 1 branch
BranchTrueFalseTotal
if $msg->code 0 0 0
46 }
47  
48 0 ▶sub save {
Subroutine save: not called CC=2 SCAR=17.9
Pod undocumented
49 # not yet be able to modify()
50 0 my ($self) = shift;
51  
52 0 my $msg = ldap()->add($self->entry);
53  
54 0 ▶ die $msg->error if $msg->code;
Branch: 1 branch
BranchTrueFalseTotal
if $msg->code 0 0 0
55 }
56  
57 18 ▶sub entry {
Subroutine entry: called CC=2 SCAR=6.9
Pod undocumented
58 18 my ($self) = shift;
59  
60 18 my $entry = Net::LDAP::Entry->new( $self->dn );
61  
62 $entry->add($_ => $self->$_)
63 18 for grep {
64 555 $self->$_
65 } grep {
66 573 !/dn/
67 } map {
68 573 $_->name
69 } $self->meta->get_all_attributes;
70  
71 18 $entry;
72 }
73  
74 7 __PACKAGE__->meta->make_immutable;
75 7 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
76  
77 7 1;
78  
79 =head1 NAME
80  
81 App::LDAP::LDIF - base class of models in App::LDAP
82  
83 =head1 SYNOPSIS
84  
85 package App::LDAP::LDIF::Animal
86  
87 use Moose;
88 with 'App::LDAP::LDIF';
89  
90 use Net::LDAP::Entry;
91  
92 has name => (
93 is => "rw",
94 isa => "Str",
95 );
96  
97 package Controller;
98 my $dog = App::LDAP::LDIF::Animal->new( name => "lucky" );
99  
100 my $dog->save;
101  
102 my $cat = App::LDAP::LDIF::Animal->find( name => "mou" );
103 say $cat->entry->ldif;
104  
105 =cut
106  
« LDAP/Role/Bindable.pm ↑ Summary LDAP/Command/Del/Ou.pm »