Sure! I've omitted the _fetch routines here, because they're not particularly relevant to the Moose portions of the code, and the size would be a bit unmanageable.

{ package LT::Library; use Moose; has 'catalog' => (is => 'ro', required => 1); has 'address' => ( is => 'ro', default => sub { my ($self) = @_; return "http://www.librarything.com/catalog/" . $self->catalog; } ); has 'books' => ( is => 'ro', isa => 'ArrayRef[LT::Book]', lazy => 1, default => sub { my ($self) = @_; my @book_addrs = _fetch_book_addrs($self->address); my @books = map { LT::Book->new(address => $_) } @book_addrs; return \@books; }, ); } { package LT::Book; use Moose; has 'address' => (is => 'ro', required => 1); has 'work' => ( is => 'ro', isa => 'LT::Work', lazy => 1, default => sub { my ($self) = @_; my ($work_address) = $self->address =~ m{(.*/work/\d+)}; return LT::Work->new(address => $work_address); }, ); } { package LT::Work; use Moose; has 'address' => (is => 'ro', required => 1); has 'title' => ( is => 'ro', isa => 'Maybe[Str]', lazy => 1, default => sub { my ($self) = @_; return _fetch_title($self->address); } ); has 'author' => ( is => 'ro', isa => 'Maybe[Str]', lazy => 1, default => sub { my ($self) = @_; return _fetch_author($self->address); } ); has 'series' => ( is => 'ro', isa => 'Maybe[LT::Series]', lazy => 1, default => sub { my ($self) = @_; my $series_addr = _fetch_series_addr($self->address); return defined $series_addr ? LT::Series->new(address => $series_addr) : (); } ); } { package LT::Series; use Moose; has 'address' => (is => 'ro', required => 1); has 'title' => ( is => 'ro', isa => 'Maybe[Str]', lazy => 1, default => sub { my ($self) = @_; return _fetch_title($self->address); } ); has 'works' => ( is => 'ro', isa => 'ArrayRef[LT::Work]', lazy => 1, default => sub { my ($self) = @_; my @work_addrs = _fetch_work_addrs($self->address); my @works = map { LT::Work->new(address => $_) } @work_addrs; return \@works; }, ); }

In reply to Re^2: Moose is lovely by revdiablo
in thread Moose is lovely by revdiablo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.