Net::LDAP::Class::MethodMaker - create methods for Net::LDAP::Class classes
package MyUser; use base qw( Net::LDAP::Class::User ); use Net::LDAP::Class::MethodMaker ( 'scalar --get_set_init' => [qw( foo )], 'related_objects' => [qw( bars )], ); __PACKAGE__->metadata->setup( base_dn => 'dc=local', attributes => [qw( foo )], unique_attributes => [qw( foo )], ); # must define a fetch_bars method sub fetch_bars { my $user = shift; # do something to get bar objects. } 1; # elsewhere my $user = MyUser->new( foo => '1234' )->read or die; $user->foo; # == $user->ldap_entry->get_value('foo'); $user->foo(5678); # == $user->ldap_entry->replace( foo => 5678 ); $user->foo; # returns '5678' my $bars = $user->bars; # == $user->fetch_bars; push(@$bars, 'new bar'); $user->bars($bars); my $newbars = $user->bars; # != $user->fetch_bars; $user->clear_bars; $newbars = $user->bars; # == $user->fetch_bars;
Net::LDAP::Class::MethodMaker is a subclass of Rose::Object::MakeMethods::Generic. It extends the base class with two new method types: related_objects and ldap_entry.
The related_objects method type creates three methods for each name when using the 'get_set' (default) interface: name, fetch_name, and clear_name.
name
fetch_name
clear_name
The fetch_ method must be defined by your class. It should return values from the LDAP server.
The name method is a get/set method. If nothing is set, it calls through to fetch_. Otherwise, if you have set something, it returns what you have set.
The clear_ method will delete any set value from the object and return it.
The ldap_entry method type supports the 'get_set' interface only.
This method type negotiates the getting and setting of values in the delegate ldap_entry() object.
Similar to the 'scalar --get-set-init' method type but may be called as a class method, in which case it will call through to the class metadata() object.
Peter Karman, <karman at cpan.org>
<karman at cpan.org>
Please report any bugs or feature requests to bug-net-ldap-class at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-LDAP-Class. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-net-ldap-class at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Net::LDAP::Class
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Net-LDAP-Class
CPAN Ratings
http://cpanratings.perl.org/d/Net-LDAP-Class
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-LDAP-Class
Search CPAN
http://search.cpan.org/dist/Net-LDAP-Class
The Minnesota Supercomputing Institute http://www.msi.umn.edu/ sponsored the development of this software.
http://www.msi.umn.edu/
Copyright 2008 by the Regents of the University of Minnesota. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Net::LDAP::Class, Rose::Object::MakeMethods::Generic
To install Net::LDAP::Class, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::LDAP::Class
CPAN shell
perl -MCPAN -e shell install Net::LDAP::Class
For more information on module installation, please visit the detailed CPAN module installation guide.