File Coverage

blib/lib/WWW/Live/Auth/Offer.pm
Criterion Covered Total %
statement 12 31 38.7
branch 0 2 0.0
condition 0 9 0.0
subroutine 4 10 40.0
pod 0 5 0.0
total 16 57 28.0


line stmt bran cond sub pod time code
1             package WWW::Live::Auth::Offer;
2              
3 1     1   5 use strict;
  1         2  
  1         36  
4 1     1   30 use warnings;
  1         3  
  1         40  
5              
6 1     1   7 use WWW::Live::Auth::Utils;
  1         1  
  1         118  
7 1     1   6 use Carp;
  1         2  
  1         464  
8              
9             sub new {
10 0     0 0   my ( $proto, %args ) = @_;
11 0   0       my $class = ref $proto || $proto;
12             my $self = bless {
13             'offer' => $args{'offer'},
14             'action' => $args{'action'},
15 0           'expires' => $args{'expires'}
16             }, $class;
17 0           $self->_process;
18 0           return $self;
19             }
20              
21             sub offer {
22 0     0 0   my ( $self ) = @_;
23 0           return $self->{'offer'};
24             }
25              
26             sub action {
27 0     0 0   my ( $self ) = @_;
28 0           return $self->{'action'};
29             }
30              
31             sub expires {
32 0     0 0   my ( $self ) = @_;
33 0           return $self->{'expires'};
34             }
35              
36             sub as_string {
37 0     0 0   my ( $self ) = @_;
38 0           return $self->offer . '.' . $self->action;
39             }
40              
41             sub _process {
42 0     0     my ( $self ) = @_;
43 0 0         if ( !$self->{'action'} ) {
44 0           my ($offer, $action, $expires) = split /[\.:]/, $self->{'offer'};
45 0   0       $self->{'offer'} = $offer || croak('Could not parse offer');
46 0   0       $self->{'action'} = $action || croak('Could not parse offer action');
47 0           $self->{'expires'}; # optional
48             }
49             }
50              
51             1;
52             __END__