Add a default but sub-classable serializing method to Meerkat::Role::Document... perhaps just expose the storage serializer?
I'm already defining the structure of the object in Mongo via Moose attributes, why should I have to do the same for a hash? This would make developing REST interfaces around Meerkat objects super simple:
For example:
package My::Model::Foo;
use Moose;
with 'Meerkat::Role::Document';
has somekey => (is => 'ro', isa => 'String');
has otherkey => (is => 'ro, isa => 'Bool');
__PACKAGE__->meta->make_immutable;
package Inside::Some::Dancer::Like::REST::Framework;
get 'things' => sub {
my $obj = meerkat->collection('foo')->find_one({somekey => 'doodad'});
return $obj? $obj->to_hash : sub {
status 404;
{ errormsg => "Can't find this thing" };
}->();
}
Add a default but sub-classable serializing method to Meerkat::Role::Document... perhaps just expose the storage serializer? I'm already defining the structure of the object in Mongo via Moose attributes, why should I have to do the same for a hash? This would make developing REST interfaces around Meerkat objects super simple:
For example: