Talk:Programming with Moose/Difficulties/Moose-w-Moose
Add topicAppearance
Latest comment: 17 years ago by EvanCarroll in topic Proposed solutions
Proposed solutions
[edit source]steven's other idea with infinite recursion
package Hash; use Moose; use Moose::Util::TypeConstraints; coerce 'Hash' => from 'HashRef' => via { Hash->new(hash => $_) }; has 'hash' => ( is => 'rw', isa => 'Hash', coerce => 1, lazy => 1, default => sub { Hash->new } ); package main; my $h = Hash->new; $h->hash->hash({ foo => 1 }); print $h->dump; EvanCarroll (talk) 17:02, 3 January 2008 (UTC)
Solution
[edit source]Since this has been written, there is a solution to this issue on the CPAN: MooseX::AttributeInflate.