File Coverage

blib/lib/Data/Sah/Type/Sortable.pm
Criterion Covered Total %
statement 21 21 100.0
branch n/a
condition n/a
subroutine 9 9 100.0
pod n/a
total 30 30 100.0


line stmt bran cond sub pod time code
1              
2             use strict;
3 21     21   8623  
  21         43  
  21         578  
4             use Data::Sah::Util::Role 'has_clause';
5 21     21   90 use Role::Tiny;
  21         36  
  21         724  
6 21     21   93  
  21         34  
  21         83  
7             requires 'superclause_sortable';
8              
9             has_clause 'min',
10             v => 2,
11             tags => ['constraint'],
12             schema => ['_same', {req=>1}],
13             allow_expr => 1,
14             code => sub {
15             my ($self, $cd) = @_;
16 370     370   844 $self->superclause_sortable('min', $cd);
17 370         1595 },
18             ;
19             has_clause 'xmin',
20             v => 2,
21             tags => ['constraint'],
22             schema => ['_same', {req=>1}],
23             allow_expr => 1,
24             code => sub {
25             my ($self, $cd) = @_;
26 128     128   250 $self->superclause_sortable('xmin', $cd);
27 128         382 },
28             ;
29             has_clause 'max',
30             v => 2,
31             prio => 51,
32             tags => ['constraint'],
33             schema => ['_same', {req=>1}],
34             allow_expr => 1,
35             code => sub {
36             my ($self, $cd) = @_;
37 237     237   445 $self->superclause_sortable('max', $cd);
38 237         748 },
39             ;
40             has_clause 'xmax',
41             v => 2,
42             prio => 51,
43             tags => ['constraint'],
44             schema => ['_same', {req=>1}],
45             allow_expr => 1,
46             code => sub {
47             my ($self, $cd) = @_;
48 174     174   319 $self->superclause_sortable('xmax', $cd);
49 174         559 },
50             ;
51             has_clause 'between',
52             v => 2,
53             tags => ['constraint'],
54             schema => ['array', {req=>1, len=>2, elems=>[
55             ['_same', {req=>1}],
56             ['_same', {req=>1}],
57             ]}],
58             allow_expr => 1,
59             code => sub {
60             my ($self, $cd) = @_;
61 1752     1752   3293 $self->superclause_sortable('between', $cd);
62 1752         5512 },
63             ;
64             has_clause 'xbetween',
65             v => 2,
66             tags => ['constraint'],
67             schema => ['array', {req=>1, len=>2, elems=>[
68             ['_same', {req=>1}],
69             ['_same', {req=>1}],
70             ]}],
71             allow_expr => 1,
72             code => sub {
73             my ($self, $cd) = @_;
74 168     168   409 $self->superclause_sortable('xbetween', $cd);
75 168         644 },
76             ;
77              
78             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
79             our $DATE = '2022-09-30'; # DATE
80             our $DIST = 'Data-Sah'; # DIST
81             our $VERSION = '0.913'; # VERSION
82              
83             1;
84             # ABSTRACT: Role for sortable types
85              
86              
87             =pod
88              
89             =encoding UTF-8
90              
91             =head1 NAME
92              
93             Data::Sah::Type::Sortable - Role for sortable types
94              
95             =head1 VERSION
96              
97             This document describes version 0.913 of Data::Sah::Type::Sortable (from Perl distribution Data-Sah), released on 2022-09-30.
98              
99             =head1 DESCRIPTION
100              
101             Role consumer must provide method C<superclause_sortable> which will receive the
102             same C<%args> as clause methods, but with additional key: C<-which> (either
103             C<min>, C<max>, C<xmin>, C<xmax>, C<between>, C<xbetween>).
104              
105             =for Pod::Coverage ^(clause_.+|clausemeta_.+)$
106              
107             =head1 HOMEPAGE
108              
109             Please visit the project's homepage at L<https://metacpan.org/release/Data-Sah>.
110              
111             =head1 SOURCE
112              
113             Source repository is at L<https://github.com/perlancar/perl-Data-Sah>.
114              
115             =head1 AUTHOR
116              
117             perlancar <perlancar@cpan.org>
118              
119             =head1 CONTRIBUTING
120              
121              
122             To contribute, you can send patches by email/via RT, or send pull requests on
123             GitHub.
124              
125             Most of the time, you don't need to build the distribution yourself. You can
126             simply modify the code, then test via:
127              
128             % prove -l
129              
130             If you want to build the distribution (e.g. to try to install it locally on your
131             system), you can install L<Dist::Zilla>,
132             L<Dist::Zilla::PluginBundle::Author::PERLANCAR>,
133             L<Pod::Weaver::PluginBundle::Author::PERLANCAR>, and sometimes one or two other
134             Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond
135             that are considered a bug and can be reported to me.
136              
137             =head1 COPYRIGHT AND LICENSE
138              
139             This software is copyright (c) 2022, 2021, 2020, 2019, 2018, 2017, 2016, 2015, 2014, 2013, 2012 by perlancar <perlancar@cpan.org>.
140              
141             This is free software; you can redistribute it and/or modify it under
142             the same terms as the Perl 5 programming language system itself.
143              
144             =head1 BUGS
145              
146             Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Data-Sah>
147              
148             When submitting a bug or request, please include a test-file or a
149             patch to an existing test-file that illustrates the bug or desired
150             feature.
151              
152             =cut