Re: Role delegation (sort of)

[email protected] (Buddy Burden) Thu, 04 Jul 2013 17:10:52 -0700
Newsgroups perl.moose
Message-ID <[email protected]>
Ben,

> Create your role Persistent which requires a number of the methods
> from MooseX::Storage and supplies the API that you want.  If $storage
> is something that does MooseX::Storage, you can then turn it into a
> Persistent thing with:
>
> Persistent->meta->apply($storage);

But this is hiding the implementation from the wrong thing, at least for 
my purposes. :-)

That is, given that $storage is an instance of type Foo (let's say), 
then Persistent doesn't know that Foo is implemented in terms of 
MooseX::Storage.  But what I'm looking for is a way that Foo won't know 
that _Persistent_ is implemented in terms of MooseX::Storage.

That make sense?  Beause then Foo's code won't need to change if I want 
to swap out back-ends; only Persistent's code will need to change, and 
then everything that is Persistent will magically use the new back-end.


		-- Buddy


(PS: how's the new job going? :-) )