File Coverage

blib/lib/Renard/Curie/Model/ViewOptions/Grid.pm
Criterion Covered Total %
statement 22 22 100.0
branch 2 2 100.0
condition 6 7 85.7
subroutine 7 7 100.0
pod 1 1 100.0
total 38 39 97.4


line stmt bran cond sub pod time code
1 1     1   285218 use Renard::Incunabula::Common::Setup;
  1         3  
  1         6  
2             package Renard::Curie::Model::ViewOptions::Grid;
3             # ABSTRACT: A set of options for grids
4             $Renard::Curie::Model::ViewOptions::Grid::VERSION = '0.003';
5 1     1   8048 use Moo;
  1         6462  
  1         4  
6 1     1   1477 use MooX::Lsub;
  1         2723  
  1         4  
7 1     1   814 use Renard::Incunabula::Common::Types qw(Maybe PositiveInt);
  1         137564  
  1         10  
8 1     1   1259 use Renard::Incunabula::Common::Error;
  1         2  
  1         157  
9              
10             # Need to use the ::BuildArgs version since is_continuous_view is a lsub.
11             with qw(MooX::BuildArgs MooX::Role::CloneSet::BuildArgs);
12              
13             has [ qw/rows columns/ ] => (
14             is => 'ro',
15             required => 1,
16             isa => sub {
17             ( Maybe[PositiveInt] )->check($_[0]) or
18             Renard::Incunabula::Common::Error::ViewOptions::InvalidGridOptions->throw(
19             msg => 'Grid extent must be Maybe[PositiveInt]',
20             );
21             },
22             );
23              
24 3     3   1294 lsub is_continuous_view => method() {
  3         8  
25 3   75     37 defined $self->rows xor
26             defined $self->columns;
27             };
28              
29 4     4 1 3502 method BUILD() {
  4         9  
30 4 100 100     46 unless( defined $self->rows or defined $self->columns ) {
31 1         8 Renard::Incunabula::Common::Error::ViewOptions::InvalidGridOptions->throw({
32             msg => "At least one of the grid extents must be defined",
33             });
34             }
35             };
36              
37             1;
38              
39             __END__
40              
41             =pod
42              
43             =encoding UTF-8
44              
45             =head1 NAME
46              
47             Renard::Curie::Model::ViewOptions::Grid - A set of options for grids
48              
49             =head1 VERSION
50              
51             version 0.003
52              
53             =head1 EXTENDS
54              
55             =over 4
56              
57             =item * L<Moo::Object>
58              
59             =back
60              
61             =head1 CONSUMES
62              
63             =over 4
64              
65             =item * L<MooX::BuildArgs>
66              
67             =item * L<MooX::BuildArgsHooks>
68              
69             =item * L<MooX::Role::CloneSet::BuildArgs>
70              
71             =back
72              
73             =head1 ATTRIBUTES
74              
75             =head2 rows
76              
77             Maybe[PositiveInt]
78              
79             The number of rows for the grid (i.e., in the vertical direction)
80             or C<undef> if the number of rows is unspecified (see C<BUILD>).
81              
82             =head2 columns
83              
84             Maybe[PositiveInt]
85              
86             The number of columns for the grid (i.e., in the horizontal direction)
87             or C<undef> if the number of columns is unspecified (see C<BUILD>).
88              
89             =head2 is_continuous_view
90              
91             Bool
92              
93             A predicate that returns a true value if the view is a continuous view
94             (see C<BUILD>).
95              
96             =head1 METHODS
97              
98             =head2 BUILD
99              
100             This class can only be constructed if at least one of C<rows> or C<columns> is
101             defined. If one is C<undef>, the associated grid view is continuous and the
102             non-C<undef> attribute is used to compute the C<undef> attribute.
103              
104             =for Pod::Coverage BUILDARGS FINALIZE_BUILDARGS
105              
106             =head1 AUTHOR
107              
108             Project Renard
109              
110             =head1 COPYRIGHT AND LICENSE
111              
112             This software is copyright (c) 2016 by Project Renard.
113              
114             This is free software; you can redistribute it and/or modify it under
115             the same terms as the Perl 5 programming language system itself.
116              
117             =cut