fix mx::traits usage and update runtime dep
[catagits/Catalyst-Model-DBIC-Schema.git] / lib / Catalyst / Model / DBIC / Schema.pm
index d1efc70..7acec2c 100644 (file)
@@ -7,6 +7,7 @@ extends 'Catalyst::Model';
 
 our $VERSION = '0.24';
 
+use namespace::autoclean;
 use Carp::Clan '^Catalyst::Model::DBIC::Schema';
 use Data::Dumper;
 use DBIx::Class ();
@@ -17,8 +18,6 @@ use Catalyst::Model::DBIC::Schema::Types
 
 use MooseX::Types::Moose qw/ArrayRef Str ClassName Undef/;
 
-use namespace::clean -except => 'meta';
-
 =head1 NAME
 
 Catalyst::Model::DBIC::Schema - DBIx::Class::Schema Model Class
@@ -91,19 +90,34 @@ be used/accessed in the normal Catalyst manner, via $c->model():
   my $actor = $c->model('FilmDB::Actor')->find(1);
 
 You can also use it to set up DBIC authentication with 
-Authentication::Store::DBIC in MyApp.pm:
+L<Catalyst::Authentication::Store::DBIx::Class> in MyApp.pm:
 
   package MyApp;
 
-  use Catalyst qw/... Authentication::Store::DBIC/;
+  use Catalyst qw/... Authentication .../;
 
   ...
 
-  __PACKAGE__->config->{authentication}{dbic} = {
-      user_class      => 'FilmDB::Actor',
-      user_field      => 'name',
-      password_field  => 'password'
-  }
+  __PACKAGE__->config->{authentication} = 
+                {  
+                    default_realm => 'members',
+                    realms => {
+                        members => {
+                            credential => {
+                                class => 'Password',
+                                password_field => 'password',
+                                password_type => 'hashed'
+                                password_hash_type => 'SHA-256'
+                            },
+                            store => {
+                                class => 'DBIx::Class',
+                                user_model => 'DB::User',
+                                role_relation => 'roles',
+                                role_field => 'rolename',                   
+                            }
+                        }
+                    }
+                };
 
 C<< $c->model('Schema::Source') >> returns a L<DBIx::Class::ResultSet> for 
 the source name parameter passed. To find out more about which methods can 
@@ -354,12 +368,12 @@ C<MyApp::Model::DB>.
 
 =head2 _default_cursor_class
 
-What to rest your L<DBIx::Class::Storage::DBI/cursor_class> if a custom one
+What to reset your L<DBIx::Class::Storage::DBI/cursor_class> to if a custom one
 doesn't work out. Defaults to L<DBIx::Class::Storage::DBI::Cursor>.
 
 =head2 _traits
 
-Unresolved arrayref of traits passed at C<COMPONENT> time.
+Unresolved arrayref of traits passed in the config.
 
 =head2 _resolved_traits
 
@@ -467,14 +481,7 @@ sub COMPONENT {
        );
     }
 
-    return $class->new(%$args);
-}
-
-# we override Catalyst::Component::BUILDARGS, which merges configs, because we
-# merge configs ourselves in COMPONENT. We also don't pass $app to ->new, so
-# Moose::Object::BUILDARGS works perfectly.
-sub BUILDARGS {
-    goto &Moose::Object::BUILDARGS;
+    return $class->new($args);
 }
 
 sub BUILD {
@@ -533,8 +540,9 @@ sub setup { 1 }
 
 =head2 ACCEPT_CONTEXT
 
-Point of extension for doing things at C<< $c->model >> time, returns the model
-instance, see L<Catalyst::Manual::Intro> for more information.
+Point of extension for doing things at C<< $c->model >> time with context,
+returns the model instance, see L<Catalyst::Manual::Intro/ACCEPT_CONTEXT> for
+more information.
 
 =cut