Re: Shimming The Moose Way

[email protected] (Niall Young) Thu, 10 Apr 2014 14:10:15 +1000 (EST)
Newsgroups perl.moose
Message-ID <[email protected]>
On Wed, 9 Apr 2014, Thalhammer, Jeffrey Ryan wrote:

> So I find myself building my own factories to do the wrapping for me.
> Architecturally, I think it makes sense.  And I like using curries to
> pass extra state into the wrappers.  But it sure requires a lot of code.
> 
> I wonder if there is a more succinct way to do this.  I want to say something like "for classes
> X, Y, and Z, always turn them into My::X and My::Y and My::Z using the interfaces that I want."
> 
> Does that make any sense?

Have you considered a configuration-driven appoach, so you could declare 1 Factory class and then configure it appropriately (with a config file, or on-the-fly construction args), to perform all of the different types of encapsulation that you could ever need to do, now and in the future?

I'd then consider distilling this behaviour down into a Moose::Role, for any Class to consume.

--
Niall Young
[email protected]