]> git.donarmstrong.com Git - class_modular.git/.git/commitdiff
* Moving around code to bring it into order with the documentation
authorDon Armstrong <don@donarmstrong.com>
Tue, 17 Feb 2004 03:08:13 +0000 (03:08 +0000)
committerDon Armstrong <don@donarmstrong.com>
Tue, 17 Feb 2004 03:08:13 +0000 (03:08 +0000)
git-svn-id: file:///srv/don_svn/class_modular/trunk@16 96c6a18b-02ce-0310-9fca-9eb62c757ba6

lib/Class/Modular.pm

index 5611de9cee97451824d2742def4383303d10e655..8fef35cc42e1aa927174bcbe487854a422e30ed2 100644 (file)
@@ -50,57 +50,6 @@ BEGIN{
 
 our $AUTOLOAD;
 
-=head2 new
-
-=head3 Usage
-
-     $obj = Foo::Bar->new();
-
-=head3 Function
-
-Creates a new C<Foo::Bar> object.
-
-Aditional arguments can be passed to this creator, and they are stored
-in C<$self->{_creation_args}>. You can also override the new method in
-your subclass. It's just provided here for completeness.
-
-=cut
-
-sub new {
-     my ($class,@args) = @_;
-
-     # We shouldn't be called $me->new, but just in case
-     $class = ref($class) || $class;
-
-     my $self = {};
-     bless $self, $class;
-
-     $self->_init(@args);
-
-     return $self;
-}
-
-
-=head2 _init
-
-=head3 Usage
-
-     $self->_init(@args);
-
-=head3 Function
-
-Stores the arguments used at new so modules that are loaded later can
-read them
-
-=cut
-
-sub _init {
-     my ($self,@creation_args) = @_;
-
-     $self->{creation_args} = [@_];
-}
-
-
 =head2 load
 
 =head3 Usage
@@ -146,46 +95,6 @@ sub load($$;$) {
      }
 }
 
-=head2 _addmethods
-
-=head3 Usage
-
-     $self->_addmethods($subclass,&{"${subclass}::_methods"}($self,$options));
-
-=head3 Function
-
-Given an array of methods, adds the methods into the _methodhash
-calling table.
-
-Methods that have previously been overridden by override are _NOT_
-overridden again. This may need to be adjusted in load.
-
-=cut
-
-sub _addmethods($@) {
-     my ($self,$subclass,@methods) = @_;
-
-     # stick the method into the table
-     # DLA: Make with the munchies!
-
-     foreach my $method (@methods) {
-         if (not $method =~ /^$subclass/) {
-              $method = $subclass.'::'.$method;
-         }
-         my ($method_name) = $method =~ /\:*([^\:]+)\s*$/;
-         if (exists $self->{_methodhash}->{$method_name}) {
-              if ($self->{_methodhash}->{$method_name}->{overridden}) {
-                   carp "Not overriding already overriden method $method_name\n" if $DEBUG;
-                   next;
-              }
-              carp "Overriding $method_name $self->{_methodhash}->{$method_name}->{reference} with $method\n";
-         }
-         $self->{_methodhash}->{$method_name}->{reference} = $method;
-         $self->{_methodhash}->{$method_name}->{subclass} = $subclass;
-     }
-
-}
-
 =head2 override
 
 =head3 Usage
@@ -331,6 +240,68 @@ sub handledby{
      return undef;
 }
 
+=head1 INTERNAL FUNCTIONS
+
+The functions below are functions internal to Class::Modular. The
+first two, new and _init should probably be overriden in any class
+that inherits from Class::Modular, but they are provided just in case
+you don't want to write a new and/or _init.
+
+=cut
+
+=head2 new
+
+=head3 Usage
+
+     $obj = Foo::Bar->new();
+
+=head3 Function
+
+Creates a new C<Foo::Bar> object.
+
+Aditional arguments can be passed to this creator, and they are stored
+in C<$self->{_creation_args}>. You can also override the new method in
+your subclass. It's just provided here for completeness.
+
+=cut
+
+sub new {
+     my ($class,@args) = @_;
+
+     # We shouldn't be called $me->new, but just in case
+     $class = ref($class) || $class;
+
+     my $self = {};
+     bless $self, $class;
+
+     $self->_init(@args);
+
+     return $self;
+}
+
+
+=head2 _init
+
+=head3 Usage
+
+     $self->_init(@args);
+
+=head3 Function
+
+Stores the arguments used at new so modules that are loaded later can
+read them
+
+This function is called by default from new. Classes may only wish to
+override _init.
+
+=cut
+
+sub _init {
+     my ($self,@creation_args) = @_;
+
+     $self->{creation_args} = [@_];
+}
+
 
 =head2 DESTROY
 
@@ -348,6 +319,48 @@ disconnected or closed.
 
 =cut
 
+=head2 _addmethods
+
+=head3 Usage
+
+     $self->_addmethods($subclass,&{"${subclass}::_methods"}($self,$options));
+
+=head3 Function
+
+Given an array of methods, adds the methods into the _methodhash
+calling table.
+
+Methods that have previously been overridden by override are _NOT_
+overridden again. This may need to be adjusted in load.
+
+=cut
+
+sub _addmethods($@) {
+     my ($self,$subclass,@methods) = @_;
+
+     # stick the method into the table
+     # DLA: Make with the munchies!
+
+     foreach my $method (@methods) {
+         if (not $method =~ /^$subclass/) {
+              $method = $subclass.'::'.$method;
+         }
+         my ($method_name) = $method =~ /\:*([^\:]+)\s*$/;
+         if (exists $self->{_methodhash}->{$method_name}) {
+              if ($self->{_methodhash}->{$method_name}->{overridden}) {
+                   carp "Not overriding already overriden method $method_name\n" if $DEBUG;
+                   next;
+              }
+              carp "Overriding $method_name $self->{_methodhash}->{$method_name}->{reference} with $method\n";
+         }
+         $self->{_methodhash}->{$method_name}->{reference} = $method;
+         $self->{_methodhash}->{$method_name}->{subclass} = $subclass;
+     }
+
+}
+
+
+
 sub DESTROY{
      my $self = shift;
      foreach my $subclass (keys %{$self->{_subclasses}}) {