in reply to Moose delegate methods, value not defined
The first error means that these are redundant:
has 'name' => ( is => 'rw', writer => 'set_name', reader => 'get_name', ); has 'email', is => 'rw'; sub set_name { my ($self, $name) = @_; $self->name = $name; } sub get_name { my $self = shift; return $self->name; }
Moose happily generates those methods for you. Let it.
That leaves:
Cannot delegate set_name to set_name because the value of author is not defined...
... which means that when you create your Post object and call $post->set_name( ... ), if $post contains no author, you get an error message to that effect. Pass in an author or create one (with a builder perhaps).
Improve your skills with Modern Perl: the free book.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Moose delegate methods, value not defined
by monktopher (Novice) on Mar 05, 2012 at 05:23 UTC | |
by ikegami (Patriarch) on Mar 05, 2012 at 06:45 UTC |