ORM.pm untested

filter: Statementstmt 0.0% 0 / 24 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod n/a totaltotal 0.0% 0 / 31 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Fey::ORM;
2 {
3 $Fey::ORM::VERSION = '0.46';
4 }
5  
6 use strict;
7 use warnings;
8  
9 use Fey 0.39;
10 use Fey::DBIManager 0.07;
11 use Moose 1.15 ();
12 use MooseX::ClassAttribute 0.24 ();
13 use MooseX::StrictConstructor 0.13 ();
14  
15 1;
16  
17 # ABSTRACT: A Fey-based ORM (If you like SQL, you might like Fey::ORM)
18  
19 __END__
20  
21 =pod
22  
23 =head1 NAME
24  
25 Fey::ORM - A Fey-based ORM (If you like SQL, you might like Fey::ORM)
26  
27 =head1 VERSION
28  
29 version 0.46
30  
31 =head1 SYNOPSIS
32  
33 A "table-based" class for the User table:
34  
35 package MyApp::Model::User;
36  
37 use MyApp::Model::Schema;
38  
39 use Fey::ORM::Table;
40  
41 my $schema = MyApp::Model::Schema->Schema();
42  
43 has_table $schema->table('User');
44  
45 has_one $schema->table('Group');
46  
47 has_many 'messages' => ( table => $schema->table('Messages') );
48  
49 C<MyApp::Model::Schema> might look like this:
50  
51 package MyApp::Model::Schema;
52  
53 use Fey::DBIManager::Source;
54 use Fey::Loader;
55  
56 use Fey::ORM::Schema;
57  
58 my $source = Fey::DBIManager::Source->new(
59 dsn => 'dbi:Pg:dbname=MyApp',
60 user => 'myapp',
61 );
62  
63 my $schema = Fey::Loader->new( dbh => $source->dbh() )->make_schema();
64  
65 has_schema $schema;
66  
67 __PACKAGE__->DBIManager()->add_source($source);
68  
69 Then in your application:
70  
71 use MyApp::Model::User;
72  
73 my $user = MyApp::Model::User->new( user_id => 1 );
74  
75 print $user->username();
76  
77 $user->update( username => 'bob' );
78  
79 =head1 DESCRIPTION
80  
81 L<Fey::ORM> builds on top of other Fey project libraries to create an
82 ORM focused on easy SQL generation. This is an ORM for people who are
83 comfortable with SQL and want to be able to use it with their objects,
84 rather than people who like OO and don't want to think about the DBMS.
85  
86 L<Fey::ORM> also draws inspiration from C<Moose> and tries to provide
87 as much functionality as it can via a simple declarative interface. Of
88 course, it uses C<Moose> under the hood for its implementation.
89  
90 =head1 EARLY VERSION WARNING
91  
92 B<This is still very new software, and APIs may change in future
93 releases without notice. You have been warned.>
94  
95 Moreover, this software is still missing a number of features which
96 will be needed to make it more easily usable and competitive with
97 other ORM packages.
98  
99 =head1 GETTING STARTED
100  
101 You should start by reading L<Fey::ORM::Manual::Intro>. This will walk
102 you through creating a set of classes based on a schema. Then look at
103 L<Fey::ORM::Manual> for a list of additional documentation.
104  
105 =head1 BUGS
106  
107 Please report any bugs or feature requests to
108 C<bug-fey-orm@rt.cpan.org>, or through the web interface at
109 L<http://rt.cpan.org>. I will be notified, and then you'll
110 automatically be notified of progress on your bug as I make changes.
111  
112 =head1 AUTHOR
113  
114 Dave Rolsky <autarch@urth.org>
115  
116 =head1 COPYRIGHT AND LICENSE
117  
118 This software is copyright (c) 2011 by Dave Rolsky.
119  
120 This is free software; you can redistribute it and/or modify it under
121 the same terms as the Perl 5 programming language system itself.
122  
123 =cut