Author: dylan
Date: 2005-01-01 17:42:10 -0500 (Sat, 01 Jan 2005)
New Revision: 509

Modified:
   trunk/main/server/lib/Haver/Server/Object/Channel.pm
Log:
documentation is more complete.


Modified: trunk/main/server/lib/Haver/Server/Object/Channel.pm
===================================================================
--- trunk/main/server/lib/Haver/Server/Object/Channel.pm        2005-01-01 
09:37:27 UTC (rev 508)
+++ trunk/main/server/lib/Haver/Server/Object/Channel.pm        2005-01-01 
22:42:10 UTC (rev 509)
@@ -2,7 +2,7 @@
 # This module is copyrighted, see end of file for details.
 =head1 NAME
 
-Haver::Server::Object::Channel - a Server::Object that contains 
Server::Objects.
+Haver::Server::Object::Channel - A Server::Object that contains 
Server::Objects.
 
 =head1 SYNOPSIS
 
@@ -50,9 +50,14 @@
        return 'channel';
 }
 
-=head2 add($object)
+=head2 add($thing)
 
+This inserts the object $thing to the contents of the channel,
+provided that $thing supports both the namespace() and id() methods,
+and C<<$channel->can_contain($thing)>> returns a true value.
 
+For Haver::Server::Object::Channel, can_contain will return true
+if C<<$thing->namespace() eq 'user'>>. This can be changed in subclasses.
 
 =cut
 
@@ -67,6 +72,25 @@
     $me->{_contents}{$ns}{$id} = $object;
 }
 
+=head2 can_contain($thing)
+
+Returns true of C<<$thing->namespace()>> is equal to 'user'.
+
+=cut
+
+sub can_contain {
+       my ($me, $object) = @_;
+       
+       $object->namespace eq 'user';
+}
+
+=head2 fetch($ns, $id)
+
+Returns the object with namespace $ns and id $id if such an object exists,
+undef otherwise.
+
+=cut
+
 sub fetch {
     my ($me, $ns, $id) = @_;
 
@@ -75,6 +99,14 @@
     return $me->{_contents}{$ns}{$id};
 }
 
+
+=head2 remove($ns, $id)
+
+Deletes and returns the object with namesapce $ns and id $id if it exists,
+returns undef otherwise.
+
+=cut
+
 sub remove {
     my ($me, $ns, $id) = @_;
 
@@ -83,6 +115,15 @@
     return delete $me->{_contents}{$ns}{$id};
 }
 
+=head2 contents($ns)
+
+Returns all objects under namespace $ns.
+Will return empty list if there are no object under the namespace.
+
+In scalar context, returns an arrayref. In list context, it returns a list.
+
+=cut
+
 sub contents {
     my ($me, $ns) = @_;
     my @values = ();
@@ -94,11 +135,52 @@
     return wantarray ? @values : [EMAIL PROTECTED];
 }
 
-sub can_contain {
-       my ($me, $object) = @_;
-       
-       not $object->isa(__PACKAGE__);
+=head2 contains($ns, $id)
+
+Returns true if an object with namespace $ns and id $id exists, false 
otherwise.
+
+=cut
+
+sub contains {
+    my ($me, $ns, $id) = @_;
+    
+    return undef unless exists $me->{_contents}{$ns};
+    return exists $me->{_contents}{$ns}{$id};
 }
 
 
+
+
 1;
+
+=head1 BUGS
+
+None known. Bug reports are welcome. Please use our bug tracker at
+L<http://gna.org/bugs/?func=additem&group=haver>.
+
+=head1 AUTHOR
+
+Dylan William Hardison, E<lt>[EMAIL PROTECTED]<gt>
+
+=head1 SEE ALSO
+
+L<Haver::Server::Object::User>, L<Haver::Server::Object::Channel>.
+
+=head1 COPYRIGHT and LICENSE
+
+Copyright (C) 2004, 2005 by Dylan Hardison
+
+This module is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This module is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this module; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+


Reply via email to