diff --git a/lib/Mongoose.pm b/lib/Mongoose.pm index c29a598..814540d 100644 --- a/lib/Mongoose.pm +++ b/lib/Mongoose.pm @@ -1,5 +1,6 @@ package Mongoose; use MongoDB; +use Class::MOP; use MooseX::Singleton; use Mongoose::Join; use Mongoose::File; @@ -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 ); } } } diff --git a/t/lib/MyTestApp/Schema/Author.pm b/t/lib/MyTestApp/Schema/Author.pm index 4f4d07e..c26c612 100644 --- a/t/lib/MyTestApp/Schema/Author.pm +++ b/t/lib/MyTestApp/Schema/Author.pm @@ -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; diff --git a/t/schema.t b/t/schema.t index b2dd7e7..10d9fd2 100644 --- a/t/schema.t +++ b/t/schema.t @@ -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;