line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MoobX::Hash::Observable; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:YANICK'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Observable role for MobX hashes |
4
|
|
|
|
|
|
|
$MoobX::Hash::Observable::VERSION = '0.1.0'; |
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
1783
|
use Moose::Role; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
25
|
|
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
10893
|
use experimental 'postderef', 'signatures'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
22
|
|
9
|
|
|
|
|
|
|
|
10
|
3
|
|
|
3
|
|
458
|
use Scalar::Util 'refaddr'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
672
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
before [ qw/ FETCH FIRSTKEY NEXTKEY EXISTS /] => sub { |
13
|
|
|
|
|
|
|
my $self = shift; |
14
|
|
|
|
|
|
|
push @MoobX::DEPENDENCIES, $self if $MoobX::WATCHING; |
15
|
|
|
|
|
|
|
}; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
after [ qw/ STORE CLEAR DELETE /] => sub { |
19
|
|
|
|
|
|
|
my $self = shift; |
20
|
|
|
|
|
|
|
for my $i ( values $self->value->%* ) { |
21
|
|
|
|
|
|
|
next if tied $i; |
22
|
|
|
|
|
|
|
next unless ref $i; |
23
|
|
|
|
|
|
|
my $type = ref $i; |
24
|
|
|
|
|
|
|
if( $type eq 'ARRAY' ) { |
25
|
|
|
|
|
|
|
MoobX::observable( @$i ); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
elsif( $type eq 'HASH' ) { |
28
|
|
|
|
|
|
|
MoobX::observable( %$i ); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
MoobX::observable_modified( $self ); |
32
|
|
|
|
|
|
|
}; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
__END__ |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=pod |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=encoding UTF-8 |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 NAME |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
MoobX::Hash::Observable - Observable role for MobX hashes |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 VERSION |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
version 0.1.0 |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 DESCRIPTION |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Role applied to L<MoobX::hash> objects to make them observables. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Used internally by L<MoobX>. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 AUTHOR |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Yanick Champoux <yanick@cpan.org> |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Yanick Champoux. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
65
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=cut |