Re: dear lazyweb: hashref instead of objects

[email protected] (Yuval Kogman)
Newsgroups perl.moose
Message-ID <[email protected]>
On Fri, Feb 08, 2008 at 19:34:43 -0500, Ricardo SIGNES wrote:

> The problem is that I do not want to write:
> 
>   coerce 'Class::A' => from 'HashRef' => via { Class::A->new($_) };
>   coerce 'Class::B' => from 'HashRef' => via { Class::B->new($_) };
>   coerce 'Class::C' => from 'HashRef' => via { Class::C->new($_) };

What about writing:

	foreach my $class ( Class::Base->meta->subclasses ) {
		coerce $class from 'HashRef' => via { $class->new($_) };
	}

?

-- 
  Yuval Kogman <[email protected]>
http://nothingmuch.woobling.org  0xEBD27418
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFHrQV9VCwRwOvSdBgRAs/KAJ9RXnI7KNrgcVLNIW9ZTgly9HW9IQCdF4dk
KFqIN83T2pT98VhkRKv+9+E=
=UssJ
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.