File Coverage

blib/lib/Fey/ORM/Types/Internal.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 16 16 100.0


line stmt bran cond sub pod time code
1             package Fey::ORM::Types::Internal;
2              
3 13     13   1554063 use strict;
  13         31  
  13         437  
4 13     13   112 use warnings;
  13         22  
  13         1672  
5              
6             our $VERSION = '0.47';
7              
8 13         150 use MooseX::Types -declare => [
9             qw(
10             ArrayRefOfClasses
11             ClassDoesIterator
12             DoesHasMany
13             DoesHasOne
14             IterableArrayRef
15             TableWithSchema
16             )
17 13     13   130 ];
  13         19  
18              
19 13     13   91002 use MooseX::Types::Moose qw( ArrayRef ClassName Object Undef );
  13         28  
  13         140  
20              
21             role_type DoesHasMany, { role => 'Fey::Meta::Role::Relationship::HasMany' };
22             role_type DoesHasOne, { role => 'Fey::Meta::Role::Relationship::HasOne' };
23              
24             #<<<
25             subtype TableWithSchema,
26             as class_type('Fey::Table'),
27             where { $_[0]->has_schema() },
28             message {
29             'A table used for has-one or -many relationships must have a schema'
30             };
31              
32             subtype ClassDoesIterator,
33             as ClassName,
34             where { $_[0]->meta()->does_role('Fey::ORM::Role::Iterator') },
35             message {"$_[0] does not do the Fey::ORM::Role::Iterator role"};
36              
37             subtype ArrayRefOfClasses,
38             as ArrayRef[ClassName],
39             where { @{$_} > 0 };
40              
41             coerce ArrayRefOfClasses,
42             from ClassName,
43             via { return [$_] };
44              
45              
46             subtype IterableArrayRef,
47             as ArrayRef[ArrayRef[Object|Undef]],
48             message {
49             'You must provide an array reference of which each '
50             . ' element is in turn an array reference. The inner '
51             . ' references should contain objects or undef.';
52             };
53              
54             coerce IterableArrayRef,
55             from ArrayRef[Object|Undef],
56             via {
57             [ map { [$_] } @{$_} ];
58             };
59             #>>>
60              
61             1;
62              
63             # ABSTRACT: Types for use in Fey::ORM
64              
65             __END__
66              
67             =pod
68              
69             =head1 NAME
70              
71             Fey::ORM::Types::Internal - Types for use in Fey::ORM
72              
73             =head1 VERSION
74              
75             version 0.47
76              
77             =head1 DESCRIPTION
78              
79             This module defines a whole bunch of types used by the Fey::ORM core
80             classes. None of these types are documented for external use at the present,
81             though that could change in the future.
82              
83             =head1 BUGS
84              
85             See L<Fey::ORM> for details on how to report bugs.
86              
87             =head1 AUTHOR
88              
89             Dave Rolsky <autarch@urth.org>
90              
91             =head1 COPYRIGHT AND LICENSE
92              
93             This software is copyright (c) 2011 - 2015 by Dave Rolsky.
94              
95             This is free software; you can redistribute it and/or modify it under
96             the same terms as the Perl 5 programming language system itself.
97              
98             =cut