line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Venus::Role::Defaultable; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
22
|
use 5.018; |
|
1
|
|
|
|
|
3
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
20
|
|
6
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
51
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use Venus::Role 'with'; |
|
1
|
|
|
|
|
19
|
|
|
1
|
|
|
|
|
9
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# BUILDERS |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub BUILD { |
13
|
2
|
|
|
2
|
0
|
8
|
my ($self) = @_; |
14
|
|
|
|
|
|
|
|
15
|
2
|
50
|
|
|
|
9
|
return $self if !$self->can('defaults'); |
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
|
|
48
|
my $defaults = $self->defaults; |
18
|
|
|
|
|
|
|
|
19
|
2
|
50
|
|
|
|
6
|
return $self if !$defaults; |
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
|
|
4
|
for my $name (@{$self->META->attrs}) { |
|
2
|
|
|
|
|
5
|
|
22
|
2
|
100
|
66
|
|
|
22
|
if (exists $defaults->{$name} && !exists $self->{$name}) { |
23
|
1
|
|
|
|
|
5
|
$self->{$name} = $defaults->{$name}; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
2
|
|
|
|
|
8
|
return $self; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
1; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 NAME |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Venus::Role::Defaultable - Defaultable Role |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=cut |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 ABSTRACT |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Defaultable Role for Perl 5 |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 SYNOPSIS |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
package Example; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
use Venus::Class 'attr', 'with'; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
with 'Venus::Role::Defaultable'; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
attr 'name'; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub defaults { |
57
|
|
|
|
|
|
|
{ |
58
|
|
|
|
|
|
|
name => 'example', |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
package main; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my $example = Example->new; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# bless({name => 'example'}, "Example") |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 DESCRIPTION |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
This package provides a mechanism for setting default values for missing |
73
|
|
|
|
|
|
|
constructor arguments. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 AUTHORS |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Awncorp, C |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=cut |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 LICENSE |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Copyright (C) 2000, Awncorp, C. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This program is free software, you can redistribute it and/or modify it under |
88
|
|
|
|
|
|
|
the terms of the Apache license version 2.0. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |