line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package EntityModel::Deferred; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$EntityModel::Deferred::VERSION = '0.102'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
use EntityModel::Class { |
6
|
1
|
|
|
|
|
12
|
_isa => [qw(Mixin::Event::Dispatch)], |
7
|
|
|
|
|
|
|
event_queue => { type => 'array', subclass => 'arrayref' }, |
8
|
1
|
|
|
1
|
|
23906
|
}; |
|
1
|
|
|
|
|
70625
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
EntityModel::Deferred - value which is not yet ready |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 VERSION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
version 0.102 |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
use EntityModel::Deferred; |
21
|
|
|
|
|
|
|
my $deferred = EntityModel::Deferred->new; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 DESCRIPTION |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 METHODS |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head2 value |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub new { |
35
|
4
|
|
|
4
|
1
|
1329
|
my $self = shift->SUPER::new; |
36
|
4
|
|
|
|
|
79
|
my %args = @_; |
37
|
4
|
100
|
|
|
|
18
|
$self->provide_value(delete $args{value}) if exists $args{value}; |
38
|
4
|
|
|
|
|
12
|
return $self; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
sub value { |
41
|
4
|
|
|
4
|
1
|
1948
|
my $self = shift; |
42
|
4
|
50
|
|
|
|
20
|
die "Value is not yet ready" unless exists $self->{value}; |
43
|
4
|
|
|
|
|
25
|
return $self->{value}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 provide_value |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub provide_value { |
51
|
5
|
|
|
5
|
1
|
913
|
my $self = shift; |
52
|
5
|
|
|
|
|
12
|
$self->{value} = shift; |
53
|
5
|
|
|
|
|
22
|
$self->invoke_event('ready' => $self->{value}); |
54
|
5
|
|
|
|
|
631
|
return $self; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 raise_error |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub raise_error { |
62
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
63
|
0
|
|
|
|
|
0
|
$self->invoke_event('error' => @_); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub add_handler { |
67
|
4
|
|
|
4
|
0
|
1362
|
my $self = shift; |
68
|
4
|
|
|
|
|
27
|
my $rslt = $self->SUPER::add_handler_for_event(@_); |
69
|
4
|
100
|
|
|
|
98
|
$self->invoke_event('ready' => $self->{value}) if exists $self->{value}; |
70
|
4
|
|
|
|
|
1537
|
return $rslt; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
__END__ |