line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SyForm::FieldRole::Default; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
6
|
|
|
6
|
|
3189
|
$SyForm::FieldRole::Default::AUTHORITY = 'cpan:GETTY'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
# ABSTRACT: A default for the field |
6
|
|
|
|
|
|
|
$SyForm::FieldRole::Default::VERSION = '0.103'; |
7
|
6
|
|
|
6
|
|
49
|
use Moo::Role; |
|
6
|
|
|
|
|
22
|
|
|
6
|
|
|
|
|
34
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has default => ( |
10
|
|
|
|
|
|
|
is => 'ro', |
11
|
|
|
|
|
|
|
predicate => 1, |
12
|
|
|
|
|
|
|
); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
around has_value_by_args => sub { |
15
|
|
|
|
|
|
|
my ( $orig, $self, %args ) = @_; |
16
|
|
|
|
|
|
|
return 1 if $self->$orig(%args); |
17
|
|
|
|
|
|
|
return 1 if $self->has_default; |
18
|
|
|
|
|
|
|
return 0; |
19
|
|
|
|
|
|
|
}; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
around get_value_by_process_args => sub { |
22
|
|
|
|
|
|
|
my ( $orig, $self, %args ) = @_; |
23
|
|
|
|
|
|
|
return $self->default if !exists($args{$self->name}) && $self->has_default; |
24
|
|
|
|
|
|
|
return $self->$orig(%args); |
25
|
|
|
|
|
|
|
}; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
1; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
__END__ |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=pod |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 NAME |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
SyForm::FieldRole::Default - A default for the field |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 VERSION |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
version 0.103 |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 AUTHOR |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Torsten Raudssus <torsten@raudss.us> |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
This software is copyright (c) 2014 by Torsten Raudssus. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
50
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |