Subject: | Class attribute setter doesn't work |
Hello,
I hope that this really a bug and not my fault.
In the following script I try to set a class attribute with a class accessor, but it doesn't work:
#!/usr/bin/perl -w
use ClassMetaTest;
# the next line doesn't work
ClassMetaTest::name("hugo");
print ClassMetaTest::name()."\n"; # Use of uninitialized value in concatenation (.) or string at cmt.pl line 7.
# setting with object accessor works fine
my $t = new ClassMetaTest();
$t->name("hugo");
print ClassMetaTest::name()."\n"; # prints hugo
File ClassMetaTest.pm:
package ClassMetaTest;
use Class::Meta;
use Class::Meta::Types::String;
BEGIN
{
my $cm = new Class::Meta();
$cm->add_constructor(
name => 'new',
create => 1,
view => Class::Meta::PUBLIC
);
$cm->add_attribute(
name => 'name',
type => 'string',
view => Class::Meta::PUBLIC,
authz => Class::Meta::RDWR,
create => Class::Meta::GETSET,
context => Class::Meta::CLASS
);
$cm->build();
}
1;
Many thanks in advance
Wolfgang