Created
November 5, 2010 17:20
-
-
Save koba04/664475 to your computer and use it in GitHub Desktop.
Class::Data::Inheritable Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
package Foo; | |
use base qw/Class::Data::Inheritable/; | |
Foo->mk_classdata('ClassName', 'Foo'); | |
1; | |
package Foo::Bar; | |
use base qw/Foo/; | |
Foo::Bar->mk_classdata('ClassName', 'Foo::Bar'); | |
sub new { | |
return bless {}, shift; | |
} | |
1; | |
package main; | |
use strict; | |
use warnings; | |
print Foo->ClassName . "\n"; | |
print Foo::Bar->ClassName . "\n"; | |
Foo::Bar->ClassName('Foo::Bar 2'); | |
print Foo->ClassName . "\n"; | |
print Foo::Bar->ClassName . "\n"; | |
my $foo_bar = Foo::Bar->new; | |
eval { | |
$foo_bar->mk_classdata('InstanceName', 'foo_bar'); | |
}; | |
print $@ . "\n"; | |
# Foo | |
# Foo::Bar | |
# Foo | |
# Foo::Bar 2 | |
# mk_classdata() is a class method, not an object method at classdate.pl line 37 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment