/[cvs]/nfo/perl/libs/Class/Tangram.pm
ViewVC logotype

Diff of /nfo/perl/libs/Class/Tangram.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by joko, Thu Oct 17 02:34:45 2002 UTC revision 1.4 by joko, Sat Nov 9 01:06:30 2002 UTC
# Line 119  attributes defined in the schema.  These Line 119  attributes defined in the schema.  These
119  available as C<$object-E<gt>function> on created objects.  By virtue  available as C<$object-E<gt>function> on created objects.  By virtue
120  of inheritance, various other methods are available.  of inheritance, various other methods are available.
121    
122  From Class::Tangram 1.12 onwards, no use of perl's C<AUTOLOAD>  From Class::Tangram 1.13 onwards, no use of perl's C<AUTOLOAD>
123  functionality is used.  functionality is used.
124    
125  =cut  =cut
# Line 162  my (%required_attributes); Line 162  my (%required_attributes);
162  # if a class is abstract, complain if one is constructed.  # if a class is abstract, complain if one is constructed.
163  my (%abstract);  my (%abstract);
164    
165    # records the inheritances of classes.
166    my (%bases);
167    
168  =head1 METHODS  =head1 METHODS
169    
170  The following methods are available for all Class::Tangram objects  The following methods are available for all Class::Tangram objects
# Line 1075  sub import_schema($) {    # Damn this fu Line 1078  sub import_schema($) {    # Damn this fu
1078              if ( my @stack = @{"${class}::ISA"}) {              if ( my @stack = @{"${class}::ISA"}) {
1079                  # clean "bases" information from @ISA                  # clean "bases" information from @ISA
1080                  my %seen = map { $_ => 1 } $class, __PACKAGE__;                  my %seen = map { $_ => 1 } $class, __PACKAGE__;
1081                  $bases = [];                  #$bases = [];   # will anything break without this? it's needed for recording inheritances later on
1082                  while ( my $super = pop @stack ) {                  while ( my $super = pop @stack ) {
1083                      if ( defined ${"${super}::schema"}                      if ( defined ${"${super}::schema"}
1084                           or defined ${"${super}::fields"} ) {                           or defined ${"${super}::fields"} ) {
# Line 1105  sub import_schema($) {    # Damn this fu Line 1108  sub import_schema($) {    # Damn this fu
1108              (ref $bases eq "ARRAY")              (ref $bases eq "ARRAY")
1109                  or die "bases not an array ref for $class";                  or die "bases not an array ref for $class";
1110    
1111                # record bases of current class for later retrieval via Run-time type information
1112                $bases{$class} = $bases;
1113    
1114              # Note that the order of your bases is significant, that              # Note that the order of your bases is significant, that
1115              # is if you are using multiple iheritance then the later              # is if you are using multiple iheritance then the later
1116              # classes override the earlier ones.              # classes override the earlier ones.
# Line 1478  sub is_abstract { Line 1484  sub is_abstract {
1484      exists $cleaners{$class} or import_schema($class);      exists $cleaners{$class} or import_schema($class);
1485  }  }
1486    
1487    =item Class::Tangram::class_bases($class)
1488    
1489    Returns an array ref of class names the given class inherits from.
1490    
1491    =cut
1492    
1493    sub class_bases($) {
1494        my $class = shift;
1495        return $bases{$class};
1496    }
1497    
1498  =item Class->set_init_default(attribute => $value);  =item Class->set_init_default(attribute => $value);
1499    
1500  Sets the default value on an attribute for newly created "Class"  Sets the default value on an attribute for newly created "Class"
# Line 1549  of the above modules, please send me an Line 1566  of the above modules, please send me an
1566    
1567  =head2 MODULE RELEASE  =head2 MODULE RELEASE
1568    
1569  This is Class::Tangram version 1.12.  This is Class::Tangram version 1.13.
1570    
1571  =head1 BUGS/TODO  =head1 BUGS/TODO
1572    

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed