Until the issues are sorted out with blogs.perl.org, I'll still be posting here for a while (probably cross-posting for a while after, too).
Recently I've wanted a simple hash object:
my $object = Hash::Object->new({ id => $some_id, this => 'that', name => 'john', }); print $object->name; # john
The problem is that current implementations I've found have limitations. One uses AUTOLOAD so any method name becomes valid. Another doesn't do that, but it also does nothing else. I'd like to be able to autoinflate an object such that if I call an unknown method, it inflates the hash object into a full-blown object and redispatches to that object, only displaying a "Can't locate object method" error if the "inflated" version of that object doesn't provide the requested method.
my $object = Hash::Object->new( data => { id => $some_id, this => 'that', name => 'john', }, inflate => sub { Customer->find({ id => shift->id }) } ); print $object->name; # inflates to full Customer object and redispatches method print $object->fullname;
The reason for this is that we sometimes have very expensive objects, but we only need one or two pieces of data from them. It would be nice to return a "proxy" object, containing the data we probably want, but will transparently work like the real thing if needed.
This is on the CPAN, yes? What's it called?
Sorry to hijack your thread but I have just tried to register unsuccessfully for the last 10 minutes. It keeps telling me the captcha text I am entering is wrong despite being 100% confident that I have it correct.
I am ready to abandon my journal here but can't seem to get registered there. About the only thing I can see that might be an issue is that I am forced to use IE and the register page says "finished but with errors".
Re:What issues with blogs.perl.org
Ovid on 2009-11-23T19:19:36
Right now it looks like it needs a lot more RAM. Dave Cross and SixApart are working on that side of things. We'll have it working, though. It's just a matter of being patient. And you're not the only person to tell me you're ready to abandon use.perl, so be patient and you'll be able to do so.
I asked a similar question a while back. The answers there may have what you're looking for.