[Catalyst-commits] r11230 - in Catalyst-Model-DBIC-Schema/trunk: .
lib/Catalyst/Model/DBIC t t/lib
caelum at dev.catalyst.perl.org
caelum at dev.catalyst.perl.org
Mon Aug 24 09:06:16 GMT 2009
Author: caelum
Date: 2009-08-24 09:06:16 +0000 (Mon, 24 Aug 2009)
New Revision: 11230
Added:
Catalyst-Model-DBIC-Schema/trunk/t/09schema_options.t
Modified:
Catalyst-Model-DBIC-Schema/trunk/Makefile.PL
Catalyst-Model-DBIC-Schema/trunk/lib/Catalyst/Model/DBIC/Schema.pm
Catalyst-Model-DBIC-Schema/trunk/t/lib/ASchemaClass.pm
Log:
remove Class::Inspector, add a test for schema options
Modified: Catalyst-Model-DBIC-Schema/trunk/Makefile.PL
===================================================================
--- Catalyst-Model-DBIC-Schema/trunk/Makefile.PL 2009-08-24 08:23:32 UTC (rev 11229)
+++ Catalyst-Model-DBIC-Schema/trunk/Makefile.PL 2009-08-24 09:06:16 UTC (rev 11230)
@@ -6,6 +6,11 @@
requires 'DBIx::Class' => '0.08107';
requires 'Catalyst::Runtime' => '5.80005';
requires 'CatalystX::Component::Traits' => '0.03';
+
+# XXX remove this once the dep in DBIC is updated, needed for schema
+# introspection to work.
+requires 'Class::Accessor::Grouped' => '0.09000';
+
requires 'Moose';
requires 'Moose::Autobox';
requires 'MooseX::Types';
@@ -13,7 +18,6 @@
requires 'Carp::Clan';
requires 'List::MoreUtils';
requires 'Tie::IxHash';
-requires 'Class::Inspector';
test_requires 'Test::More';
test_requires 'Test::Exception';
Modified: Catalyst-Model-DBIC-Schema/trunk/lib/Catalyst/Model/DBIC/Schema.pm
===================================================================
--- Catalyst-Model-DBIC-Schema/trunk/lib/Catalyst/Model/DBIC/Schema.pm 2009-08-24 08:23:32 UTC (rev 11229)
+++ Catalyst-Model-DBIC-Schema/trunk/lib/Catalyst/Model/DBIC/Schema.pm 2009-08-24 09:06:16 UTC (rev 11230)
@@ -12,7 +12,6 @@
use Data::Dumper;
use DBIx::Class ();
use Moose::Autobox;
-use Class::Inspector ();
use Catalyst::Model::DBIC::Schema::Types
qw/ConnectInfo LoadedClass/;
@@ -200,6 +199,8 @@
=head1 CONFIG PARAMETERS
+Any options in your config not listed here are passed to your schema.
+
=head2 schema_class
This is the classname of your L<DBIx::Class::Schema> Schema. It needs
@@ -263,6 +264,7 @@
on_connect_do some SQL statement
on_connect_do another SQL statement
</connect_info>
+ user_defined_schema_accessor foo
</Model::FilmDB>
or
@@ -276,14 +278,14 @@
Model::MyDB:
schema_class: MyDB
+ traits: Caching
connect_info:
dsn: dbi:Oracle:mydb
user: mtfnpy
password: mypass
LongReadLen: 1000000
LongTruncOk: 1
- on_connect_do: [ "alter session set nls_date_format = 'YYYY-MM-DD HH24:MI:SS'" ]
- cursor_class: 'DBIx::Class::Cursor::Cached'
+ on_connect_call: 'datetime_setup'
quote_char: '"'
The old arrayref style with hashrefs for L<DBI> then L<DBIx::Class> options is also
@@ -590,8 +592,8 @@
sub _delegates {
my $self = shift;
-# XXX change this to CMOP once CAG is updated
- my @schema_methods = @{ Class::Inspector->methods($self->schema_class) };
+ my $schema_meta = Class::MOP::Class->initialize($self->schema_class);
+ my @schema_methods = $schema_meta->get_all_method_names;
# combine with any already added by other schemas
my @handles = eval {
@@ -599,7 +601,7 @@
};
# now kill the attribute, otherwise add_attribute in BUILD will not do the right
-# thing. May be a Moose bug.
+# thing (it clears the handles for some reason.) May be a Moose bug.
eval { $self->meta->remove_attribute('schema') };
my %schema_methods;
Added: Catalyst-Model-DBIC-Schema/trunk/t/09schema_options.t
===================================================================
--- Catalyst-Model-DBIC-Schema/trunk/t/09schema_options.t (rev 0)
+++ Catalyst-Model-DBIC-Schema/trunk/t/09schema_options.t 2009-08-24 09:06:16 UTC (rev 11230)
@@ -0,0 +1,28 @@
+use strict;
+use warnings;
+
+use FindBin '$Bin';
+use lib "$Bin/lib";
+
+use Test::More;
+use Test::Exception;
+use Catalyst::Model::DBIC::Schema;
+use ASchemaClass;
+
+plan tests => 4;
+
+ok((my $m = instance(a_schema_option => 'mtfnpy')), 'instance');
+
+is $m->schema->a_schema_option, 'mtfnpy', 'option was passed from config';
+
+lives_ok { $m->a_schema_option('pass the crack pipe') } 'delegate called';
+
+is $m->schema->a_schema_option, 'pass the crack pipe', 'delegation works';
+
+sub instance {
+ Catalyst::Model::DBIC::Schema->new({
+ schema_class => 'ASchemaClass',
+ connect_info => ['dbi:SQLite:foo.db', '', ''],
+ @_,
+ })
+}
Modified: Catalyst-Model-DBIC-Schema/trunk/t/lib/ASchemaClass.pm
===================================================================
--- Catalyst-Model-DBIC-Schema/trunk/t/lib/ASchemaClass.pm 2009-08-24 08:23:32 UTC (rev 11229)
+++ Catalyst-Model-DBIC-Schema/trunk/t/lib/ASchemaClass.pm 2009-08-24 09:06:16 UTC (rev 11230)
@@ -2,6 +2,8 @@
use base 'DBIx::Class::Schema';
+__PACKAGE__->mk_group_accessors(inherited => 'a_schema_option');
+
__PACKAGE__->load_classes;
1;
More information about the Catalyst-commits
mailing list