line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CMS::Drupal::Modules::MembershipEntity::Membership; |
2
|
|
|
|
|
|
|
$CMS::Drupal::Modules::MembershipEntity::Membership::VERSION = '0.96'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Perl interface to a Drupal MembershipEntity membership |
4
|
|
|
|
|
|
|
|
5
|
10
|
|
|
10
|
|
52
|
use strict; |
|
10
|
|
|
|
|
19
|
|
|
10
|
|
|
|
|
242
|
|
6
|
10
|
|
|
10
|
|
49
|
use warnings; |
|
10
|
|
|
|
|
17
|
|
|
10
|
|
|
|
|
313
|
|
7
|
|
|
|
|
|
|
|
8
|
10
|
|
|
10
|
|
47
|
use Moo; |
|
10
|
|
|
|
|
19
|
|
|
10
|
|
|
|
|
155
|
|
9
|
10
|
|
|
10
|
|
3361
|
use Types::Standard qw/ :all /; |
|
10
|
|
|
|
|
19
|
|
|
10
|
|
|
|
|
72
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has mid => ( is => 'ro', isa => Int, required => 1 ); |
12
|
|
|
|
|
|
|
has created => ( is => 'ro', isa => Int, required => 1 ); |
13
|
|
|
|
|
|
|
has changed => ( is => 'ro', isa => Int, required => 1 ); |
14
|
|
|
|
|
|
|
has uid => ( is => 'ro', isa => Int, required => 1 ); |
15
|
|
|
|
|
|
|
has status => ( is => 'ro', isa => Enum[ qw/0 1 2 3/ ], required => 1 ); |
16
|
|
|
|
|
|
|
has member_id => ( is => 'ro', isa => Str, required => 1 ); |
17
|
|
|
|
|
|
|
has type => ( is => 'ro', isa => Str, required => 1 ); |
18
|
|
|
|
|
|
|
has terms => ( is => 'ro', isa => HashRef, required => 1 ); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub is_expired { |
22
|
29
|
|
|
29
|
1
|
34
|
my $self = shift; |
23
|
29
|
100
|
|
|
|
74
|
$self->{'_is_expired'} = $self->{'status'} eq '0' ? 1 : 0; |
24
|
29
|
|
|
|
|
101
|
return $self->{'_is_expired'}; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub is_active { |
29
|
33
|
|
|
33
|
1
|
20913
|
my $self = shift; |
30
|
33
|
100
|
|
|
|
73
|
$self->{'_is_active'} = $self->{'status'} eq '1' ? 1 : 0; |
31
|
33
|
|
|
|
|
118
|
return $self->{'_is_active'}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub is_cancelled { |
36
|
29
|
|
|
29
|
1
|
31
|
my $self = shift; |
37
|
29
|
50
|
|
|
|
65
|
$self->{'_is_cancelled'} = $self->{'status'} eq '2' ? 1 : 0; |
38
|
29
|
|
|
|
|
130
|
return $self->{'_is_cancelled'}; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub is_pending { |
43
|
29
|
|
|
29
|
1
|
32
|
my $self = shift; |
44
|
29
|
50
|
|
|
|
62
|
$self->{'_is_pending'} = $self->{'status'} eq '3' ? 1 : 0; |
45
|
29
|
|
|
|
|
91
|
return $self->{'_is_pending'}; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub has_renewal { |
50
|
3
|
|
|
3
|
1
|
554
|
my $self = shift; |
51
|
3
|
|
|
|
|
19
|
$self->{'_has_renewal'} = 0; |
52
|
3
|
|
|
|
|
7
|
foreach my $term ( values %{ $self->{'terms'} } ) { |
|
3
|
|
|
|
|
19
|
|
53
|
5
|
100
|
100
|
|
|
26
|
$self->{'_has_renewal'} = 1 if ($term->is_future and $term->is_active); |
54
|
|
|
|
|
|
|
} |
55
|
3
|
|
|
|
|
63
|
return $self->{'_has_renewal'}; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub current_was_renewal { |
60
|
29
|
|
|
29
|
1
|
34
|
my $self = shift; |
61
|
29
|
|
|
|
|
42
|
$self->{'_current_was_renewal'} = 0; |
62
|
29
|
|
|
|
|
31
|
foreach my $term ( values %{ $self->{'terms'} } ) { |
|
29
|
|
|
|
|
63
|
|
63
|
33
|
100
|
100
|
|
|
80
|
$self->{'_current_was_renewal'} = 1 if ($term->is_current and $term->was_renewal); |
64
|
|
|
|
|
|
|
} |
65
|
29
|
|
|
|
|
96
|
return $self->{'_current_was_renewal'}; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; ## return true to end package MembershipEntity::Membership |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
__END__ |