http://www.perlmonks.org?node_id=927928


in reply to How do you create attribute handlers for methods of an object (via Moose) ?

This question was also posed on StackOverflow, where I answered the following.


Are you simply overcomplicating things, or am I missing something?

package Bucket; has '_linkedlist' => ( is => 'rw', isa => 'LinkedList', handles => { _add_link => 'append', _insert_link => 'insert', _count_links => 'size', _del_link => 'remove', _split_at_link => 'split', _has_sublinks => 'has_children', }, );

Hashes don't have methods, which is why a trait is involves. The trait adds the methods. Your LinkedList class has methods, so no need to write a trait to provide the methods.

  • Comment on Re: How do you create attribute handlers for methods of an object (via Moose) ?
  • Download Code