Skip to content

Instantly share code, notes, and snippets.

@koba04
Created November 5, 2010 17:20
Show Gist options
  • Save koba04/664475 to your computer and use it in GitHub Desktop.
Save koba04/664475 to your computer and use it in GitHub Desktop.
Class::Data::Inheritable Test
#!/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