-
-
04 Sep 2014 10:42:48 UTC
- Distribution: Catalyst-Model-DBIC-Schema
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Clone repository
- Issues (6)
- Testers (7492 / 43 / 5)
- Kwalitee
Bus factor: 11- 66.67% Coverage
- License: perl_5
- Perl: v5.8.1
- Activity
24 month- Tools
- Download (56.06KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
and 1 contributors- Brandon L Black C<blblack at gmail.com>
- Dependencies
- Carp::Clan
- Catalyst::Component::InstancePerContext
- Catalyst::Runtime
- CatalystX::Component::Traits
- DBIx::Class
- DBIx::Class::Schema::Loader
- Hash::Merge
- List::MoreUtils
- Module::Runtime
- Moose
- MooseX::MarkAsMethods
- MooseX::NonMoose
- MooseX::Types
- MooseX::Types::LoadableClass
- Tie::IxHash
- Try::Tiny
- namespace::autoclean
- namespace::clean
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
- NAME
- DESCRIPTION
- CREATING SCHEMA CONFIG ATTRIBUTES
- CREATING RESULTSET CONFIG ATTRIBUTES
- SEE ALSO
- AUTHOR
- COPYRIGHT
- LICENSE
NAME
Catalyst::TraitFor::Model::DBIC::Schema::SchemaProxy - Proxy Schema Methods and Options from Model
DESCRIPTION
Allows you to call your DBIx::Class::Schema methods directly on the Model instance, and passes config options to your DBIx::Class::Schema and DBIx::Class::ResultSet attributes at
BUILD
time.Methods and attributes local to your
Model
take precedence over DBIx::Class::Schema or DBIx::Class::ResultSet methods and attributes.CREATING SCHEMA CONFIG ATTRIBUTES
To create attributes in your
Schema.pm
, use either Moose or Class::Accessor::Grouped, which is inherited from by all DBIx::Class classes automatically. E.g.:__PACKAGE__->mk_group_accessors(simple => qw/ config_key1 config_key2 ... /);
Or with Moose:
use Moose; has config_key1 => (is => 'rw', default => 'default_value');
This code can be added after the md5sum on DBIx::Class::Schema::Loader generated schemas.
At app startup, any non-local options will be passed to these accessors, and can be accessed as usual via
$schema->config_key1
.These config values go into your
Model::DB
block, along with normal config values.CREATING RESULTSET CONFIG ATTRIBUTES
You can create classdata on DBIx::Class::ResultSet classes to hold values from Catalyst config.
The code for this looks something like this:
package MySchema::ResultSet::Foo; use base 'DBIx::Class::ResultSet'; __PACKAGE__->mk_group_accessors(inherited => qw/ rs_config_key1 rs_config_key2 ... /); __PACKAGE__->rs_config_key1('default_value');
Or, if you prefer Moose:
package MySchema::ResultSet::Foo; use Moose; use MooseX::NonMoose; use MooseX::ClassAttribute; extends 'DBIx::Class::ResultSet'; sub BUILDARGS { $_[2] } # important class_has rs_config_key1 => (is => 'rw', default => 'default_value'); ... __PACKAGE__->meta->make_immutable; 1;
In your catalyst config, use the generated Model name as the config key, e.g.:
<Model::DB::Users> strict_passwords 1 </Model::DB::Users>
SEE ALSO
Catalyst::Model::DBIC::Schema, DBIx::Class::Schema
AUTHOR
See "AUTHOR" in Catalyst::Model::DBIC::Schema and "CONTRIBUTORS" in Catalyst::Model::DBIC::Schema.
COPYRIGHT
See "COPYRIGHT" in Catalyst::Model::DBIC::Schema.
LICENSE
This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself.
Module Install Instructions
To install Catalyst::Model::DBIC::Schema, copy and paste the appropriate command in to your terminal.
cpanm Catalyst::Model::DBIC::Schema
perl -MCPAN -e shell install Catalyst::Model::DBIC::Schema
For more information on module installation, please visit the detailed CPAN module installation guide.