MongoDBx::Class::EmbeddedDocument - A MongoDBx::Class embedded (sub-)document role
version 1.030002
# create an embedded document class package MyApp::Schema::PersonName; use MongoDBx::Class::Moose; # use this instead of Moose use namespace::autoclean; with 'MongoDBx::Class::EmbeddedDocument'; has 'first_name' => (is => 'ro', isa => 'Str', required => 1, writer => 'set_first_name'); has 'middle_name' => (is => 'ro', isa => 'Str', predicate => 'has_middle_name', writer => 'set_middle_name'); has 'last_name' => (is => 'ro', isa => 'Str', required => 1, writer => 'set_last_name'); sub name { my $self = shift; my $name = $self->first_name; $name .= ' '.$self->middle_name.' ' if $self->has_middle_name; $name .= $self->last_name; return $name; } __PACKAGE__->meta->make_immutable;
MongoDBx::Class::EmbeddedDocument is a Moose role meant to be consumed by document classes representing embedded documents. These are documents that are entirely contained within parent MongoDB documents.
The role provides expanded embedded documents with some common attributes and useful methods.
The MongoDBx::Class::Collection object representing the MongoDB collection in which this embedded document is stored (more correctly, the collection in which the MongoDBx::Class::Document holding this embedded document is stored). This is a required attribute.
A string. The name of the document class of this embedded document. A required attribute.
The following methods are provided:
Returns the embedded document as a hash reference, without the _collection and _class attributes (if they exist).
Convenience shortcut for running $embd_doc->_collection->_database.
$embd_doc->_collection->_database
Returns a list of names of all attributes the embedded document object has, minus '_collection' and '_class', sorted alphabetically.
Ido Perlmuter, <ido at ido50.net>
<ido at ido50.net>
Please report any bugs or feature requests to bug-mongodbx-class at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MongoDBx-Class. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-mongodbx-class at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc MongoDBx::Class::EmbeddedDocument
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=MongoDBx::Class
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/MongoDBx::Class
CPAN Ratings
http://cpanratings.perl.org/d/MongoDBx::Class
Search CPAN
http://search.cpan.org/dist/MongoDBx::Class/
MongoDBx::Class::Moose, MongoDBx::Class::Document.
Copyright 2010-2014 Ido Perlmuter.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install MongoDBx::Class, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MongoDBx::Class
CPAN shell
perl -MCPAN -e shell install MongoDBx::Class
For more information on module installation, please visit the detailed CPAN module installation guide.