blib/lib/Term/Fabulous/Role/HasRange.pm untested

filter: Statementstmt 0.0% 0 / 28 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod n/a totaltotal 0.0% 0 / 35 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Term::Fabulous::Role::HasRange;
2  
3 use v5.32;
4 use warnings;
5 use feature 'signatures';
6 no warnings 'experimental::signatures';
7  
8 our $VERSION = '0.05';
9  
10 use Object::Pad 0.825;
11  
12 role Term::Fabulous::Role::HasRange {
13  
14 # The layout properties that make the range (a class method), applied
15 # together and before the others.
16 method range_properties;
17  
18 # Changes the range: the given parts together, checked as a whole.
19 method set_range;
20  
21 # A layout gives min, max, step, ... in any order and the value
22 # anywhere among them: the range is set in one go first, so it never
23 # passes through a state that is no range, and the value comes after.
24 method apply_layout_settings (@settings) {
25 my %in_range = map { $_ => 1 } ref($self)->range_properties;
26 my %range = map { @$_ } grep { $in_range{ $_->[0] } } @settings;
27 $self->set_range(%range) if %range;
28 return $self->next::method( grep { !$in_range{ $_->[0] } } @settings );
29 }
30 }
31  
32 1;
33  
34 __END__