Re: Initialization Impasse

[email protected]
Newsgroups perl.moose
Message-ID <[email protected]>
Stevan Little wrote:

> Yes, take a look at the predicate option, it is currently only
> documented in Class::MOP::Attribute, but you use it like this:
> 
> has 'foo' => (is => 'rw', predicate => 'has_foo');
> 
> If foo has never been set, then $obj->has_foo will return false, if
> foo has been set (even with undef) then it will return true.

Oh, duh. I knew about that. Or rather, I had known, and somehow the fact
that the predicate tests for initializedness had receded to the back of my
mind... It works beautifully, of course, thanks a lot for the tip.


> Hmm, Moose can't really help this. I suggest breaking the cycle at
> some point, or if you cant, looking into a proxy object I wrote one
> for Bread::Board recently (http://search.cpan.org/~stevan/Bread-
> Board-0.03/lib/Bread/Board/Service/Deferred.pm).

Hmm, I'll have to think harder on how to break the cycle. The idea of the
proxy object is interesting (and your Bread::Box even more so), but for
right now I'll have to live with what I have. Just knowing that this issue
is mostly outside the scope of Moose is already helpful, one place to bang
my head against.

Bernardo
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.