From: Kartik S. <kar...@us...> - 2003-02-22 18:26:41
|
Update of /cvsroot/perl-ldap/ldap/lib/Net/LDAP In directory sc8-pr-cvs1:/tmp/cvs-serv948 Modified Files: Entry.pm Entry.pod Log Message: Added clone() function to copy an Entry object. Index: Entry.pm =================================================================== RCS file: /cvsroot/perl-ldap/ldap/lib/Net/LDAP/Entry.pm,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- Entry.pm 28 May 2002 08:13:32 -0000 1.10 +++ Entry.pm 22 Feb 2003 18:26:39 -0000 1.11 @@ -9,7 +9,7 @@ use Net::LDAP::Constant qw(LDAP_LOCAL_ERROR); use vars qw($VERSION); -$VERSION = "0.17"; +$VERSION = "0.18"; sub new { my $self = shift; @@ -18,6 +18,18 @@ my $entry = bless { 'changetype' => 'add', changes => [] }, $type; $entry; +} + +sub clone { + my $self = shift; + my $clone = $self->new(); + + $clone->dn($self->dn()); + foreach ($self->attributes()) { + $clone->add($_ => [$self->get_value($_)]); + } + + $clone; } # Build attrs cache, created when needed Index: Entry.pod =================================================================== RCS file: /cvsroot/perl-ldap/ldap/lib/Net/LDAP/Entry.pod,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- Entry.pod 18 Jun 2002 12:39:12 -0000 1.9 +++ Entry.pod 22 Feb 2003 18:26:39 -0000 1.10 @@ -22,7 +22,7 @@ use Net::LDAP::Entry; $entry = Net::LDAP::Entry->new; - + $entry->add( attr1 => 'value1', attr2 => [qw(value1 value2)] @@ -34,9 +34,11 @@ attr1 => 'newvalue' attr2 => [qw(new values)] ); - + $entry->update( $ldap ); # update directory server + $entry2 = $entry->clone; # copies entry + =head1 DESCRIPTION The B<Net::LDAP::Entry> object represents a single entry in the directory. @@ -51,13 +53,17 @@ entry. Entries for this purpose can also be created by reading an LDIF file with the L<Net::LDAP::LDIF> module. -=head1 CONSTRUCTOR +=head1 CONSTRUCTORS =over 4 =item new Create a new entry object with the changetype set to C<'add'> + +=item clone + +Returns a copy of the B<Net::LDAP::Entry> object. =back |