Skip to content

Commit

Permalink
clone meta object during load_schema shortening
Browse files Browse the repository at this point in the history
  • Loading branch information
xdg committed Jan 18, 2013
1 parent 39e9b39 commit 8ac44e4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/Mongoose.pm
@@ -1,5 +1,6 @@
package Mongoose;
use MongoDB;
use Class::MOP;
use MooseX::Singleton;
use Mongoose::Join;
use Mongoose::File;
Expand Down Expand Up @@ -116,8 +117,8 @@ sub load_schema {
my $short_name = $1;
no strict 'refs';
*{ $short_name . "::" } = \*{ $module . "::" };
$short_name->meta->{mongoose_config} =
$module->meta->{mongoose_config};
Class::MOP::store_metaclass_by_name( $short_name, $module->meta );
Class::MOP::weaken_metaclass( $short_name );
}
}
}
Expand Down
1 change: 1 addition & 0 deletions t/lib/MyTestApp/Schema/Author.pm
Expand Up @@ -3,5 +3,6 @@ use Moose;
with 'Mongoose::Document' => { -collection_name=>'author' };

has 'name' => ( is=>'rw', isa=>'Str' );
has 'timestamp' => ( is => 'ro', isa => 'Num', default => sub { time } );

1;
3 changes: 3 additions & 0 deletions t/schema.t
Expand Up @@ -21,4 +21,7 @@ $au->save;

is ref($au), 'MyTestApp::Schema::Author', 'schema found';

my $au2 = Author->find_one( {name =>'Bob'} );
is $au->timestamp, $au2->timestamp, "roundtrip";

done_testing;

0 comments on commit 8ac44e4

Please sign in to comment.