support coderefs for loader options for helper
[catagits/Catalyst-Model-DBIC-Schema.git] / lib / Catalyst / Helper / Model / DBIC / Schema.pm
index 03f9741..4951027 100644 (file)
@@ -4,7 +4,7 @@ use namespace::autoclean;
 use Moose;
 no warnings 'uninitialized';
 
-our $VERSION = '0.31';
+our $VERSION = '0.32';
 $VERSION = eval $VERSION;
 
 use Carp;
@@ -107,6 +107,14 @@ Same, but with extra Schema::Loader args (separate multiple values by commas):
     exclude='^(wibble|wobble)$' moniker_map='{ foo => "FOO" }' \
     dbi:Pg:dbname=foodb myuname mypass
 
+Coderefs are also supported:
+
+  script/myapp_create.pl model CatalystModelName DBIC::Schema \
+    MyApp::SchemaClass create=static \
+    inflect_singular='sub { $_[0] =~ /\A(.+?)(_id)?\z/; $1 }' \
+    moniker_map='sub { join(q{}, map ucfirst, split(/[\W_]+/, lc $_[0])); }' \
+    dbi:mysql:foodb myuname mypass
+
 See L<DBIx::Class::Schema::Loader::Base> for a list of options
 
 Create a dynamic DBIx::Class::Schema::Loader-based Schema,
@@ -455,7 +463,7 @@ sub _parse_connect_info {
 sub _is_struct {
     my ($self, $val) = @_;
 
-    return $val =~ /^\s*[[{]/;
+    return $val =~ /^\s*(?:sub|[[{])/;
 }
 
 sub _quote {