Hi, I have a requirement for which I think Traits will be a solution. I have a class - MyClass that the users subclass to use it. The users add attributes to the subclass, some of which need a default value to be picked up from a config file. So, I want to allow the users to indicate that the default value needs to be loaded from config file via a trait - SpecialAttributes
package SubClass;
use Moose;
extends 'MyClass';
for (qw/apple mango banana/) {
has $_ => (
is => 'rw',
isa => 'Str',
traits => [qw/SpecialAttributes/],
);
}
package main;
my $c=SubClass->new;
print $c->apple,"\n";
I get this error when I run the program (I've attached Main.pl and
SpecialArguments.pm for reference)
Can't use an undefined value as a HASH reference at
/home/y/lib/perl5/site_perl/5.8/i686-linux-64int/Moose/Meta/Attribute/Native/MethodProvider/Hash.pm
line 22.
I'd appreciate it very very much if you could give me a solution.
I've pasted the code here - http://hpaste.org/40028/moose_code since I
am not sure if the list supports attachments.
--
Regards,
Kashyap
Main.pl
Description: Binary data
SpecialAttributes.pm
Description: Binary data
