-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME
More file actions
85 lines (64 loc) · 2.56 KB
/
Copy pathREADME
File metadata and controls
85 lines (64 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
NAME
Catalyst::TraitFor::Model::DBIC::Shortcut - shortcuts support for DBIC
models
VERSION
Version 0.02
SYNOPSIS
#
# application class
#
package TestApp;
use Moose;
use namespace::autoclean;
use Catalyst qw/ ......... /;
extends 'Catalyst';
with 'Catalyst::TraitFor::Model::DBIC::Shortcut';
#
# controller class
#
package TestApp::Controller::Test;
.........
# these two calls are the same
my $s = $c->model('DB')->schema;
my $s = $c->db_schema;
.........
# these two calls are the same
my $rs = $c->model('DB::Actor');
my $rs = $c->db_actor_rs;
.........
DESCRIPTION
If you got tired of writting "$c->model('DB::Actor')" each time, or if
you use auto-completion intensively, you could look at this trait. Just
use this role in your application class, and you'll have shortcuts
auto-created for all DBIx::Class-based models:
- schema
for all schema classes, based on Catalyst::Model::DBIC::Schema,
you'll get method with name "lowercase class name" + "_schema", with
all "::" converted to underscore ("_"):
$c->model('DB')->schema ==> $c->db_schema
$c->model('DBIC')->schema ==> $c->dbic_schema
$c->model('DBIC::DB1')->schema ==> $c->dbic_db1_schema
- resultset
for all resultset classes, based on DBIx::Class, you'll get method
with name "lowercase class name" + "_rs", with all "::" converted to
underscore ("_"):
$c->model('DB::Actor') ==> $c->db_actor_rs
$c->model('DB::Track') ==> $c->db_track_rs
$c->model('DBIC::DB1::Actor') ==> $c->dbic_db1_actor_rs
GIT REPOSITORY
git clone
git://github.com/cub-uanic/Catalyst-TraitFor-Model-DBIC-Shortcut.git
SEE ALSO
Catalyst, DBIx::Class, Moose
AUTHOR
Oleg Kostyuk, "<cub#cpan.org>"
Based on ideas from from Pedro Melo and Oleg Pronin
<http://lists.scsys.co.uk/pipermail/dbix-class/2010-January/008794.html>
<http://lists.scsys.co.uk/pipermail/dbix-class/2010-February/008903.html
>
COPYRIGHT & LICENSE
Copyright by Oleg Kostyuk.
This program is free software; you can redistribute it and/or modify it
under the terms of either: the GNU General Public License as published
by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.