blib/lib/IO/Iron/IronMQ/Message.pm

filter: Statementstmt 43.8% 25 / 57 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 55.5% 10 / 18 Podpod 100% 7 / 7 totaltotal 44.6% 42 / 94 CC 7 SCAR 24.8
CC
7
Cov
36%
new
42.0
_access_internal
6.0
body
2.0
CRAP 11.9
« blib/lib/IO/Iron/IronMQ/Client.pm ↑ Summary blib/lib/IO/Iron/PolicyBase.pm »
1 package IO::Iron::IronMQ::Message;
2  
3 ## no critic (Documentation::RequirePodAtEnd)
4 ## no critic (Documentation::RequirePodSections)
5 ## no critic (Subroutines::RequireArgUnpacking)
6  
7 3 ▶use 5.010_000;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 # Global creator
12 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
13 }
14  
15 # Global destructor
16 ▶END {
Subroutine END: called CC=1 SCAR=0.0
17 }
18  
19  
20 # ABSTRACT: IronMQ (Online Message Queue) Client (Message).
21  
22 3 our $VERSION = '0.12_01'; # TRIAL VERSION: generated by DZP::OurPkgVersion
23  
24  
25  
26 3 ▶use Log::Any qw($log);
Subroutine BEGIN: called CC=1 SCAR=0.0
27 3 ▶use Hash::Util 0.06 qw{lock_keys unlock_keys};
Subroutine BEGIN: called CC=1 SCAR=0.0
28 3 ▶use Carp::Assert::More;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 3 ▶use English '-no_match_vars';
Subroutine BEGIN: called CC=1 SCAR=0.0
30 3 ▶use Params::Validate qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32 # CONSTANTS for this module
33  
34 # DEFAULTS
35  
36  
37 sub new {
38 0 ▶ my $class = shift;
Subroutine new: not called CC=6 SCAR=37.4
Pod documented
39 0 my %params = validate(
40 @_, {
41 'body' => { type => SCALAR, }, # Message body (free text), can be empty.
42 'delay' => { type => SCALAR, optional => 1, }, # The item will not be available on the queue until this many seconds have passed.
43 'push_headers' => { type => HASHREF, optional => 1, }, # Headers for push queues.
44 'id' => { type => SCALAR, optional => 1, }, # Message id from IronMQ queue (after message has been reserved/peeked).
45 'reserved_count' => { type => SCALAR, optional => 1, }, # FIXME item reserved_count
46 'reservation_id' => { type => SCALAR, optional => 1, }, # Reservation id string from the queue.
47 }
48 );
49 0 $log->tracef('Entering new(%s, %s)', $class, %params);
50 0 my $self;
51 0 my @self_keys = ( ## no critic (CodeLayout::ProhibitQuotedWordLists)
52 'body', # Message body (free text), can be empty.
53 'delay', # The item will not be available on the queue until this many seconds have passed.
54 'push_headers', # Push queue headers.
55 'id', # Message id from IronMQ queue (after message has been pulled/peeked).
56 'reserved_count', # FIXME item reserved_count
57 'reservation_id', # reservation_id
58 );
59 0 lock_keys(%{$self}, @self_keys);
60 0 $self->{'body'} = $params{'body'};
61 0 ▶ $self->{'delay'} = defined $params{'delay'} ? $params{'delay'} : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $params{'delay'} ? : 0 0 0
62 0 ▶ $self->{'push_headers'} = defined $params{'push_headers'} ? $params{'push_headers'} : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $params{'push_headers'} ? : 0 0 0
63 0 ▶ $self->{'id'} = defined $params{'id'} ? $params{'id'} : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $params{'id'} ? : 0 0 0
64 0 ▶ $self->{'reserved_count'} = defined $params{'reserved_count'} ? $params{'reserved_count'} : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $params{'reserved_count'} ? : 0 0 0
65 0 ▶ $self->{'reservation_id'} = defined $params{'reservation_id'} ? $params{'reservation_id'} : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $params{'reservation_id'} ? : 0 0 0
66 # All of the above can be undefined, except the body: the message can not be empty.
67 # If delay is undefined, the IronMQ defaults (at the server) will be used.
68  
69 0 unlock_keys(%{$self});
70 0 my $blessed_ref = bless $self, $class;
71 0 lock_keys(%{$self}, @self_keys);
72  
73 0 $log->tracef('Exiting new: %s', $blessed_ref);
74 0 return $blessed_ref;
75 }
76  
77  
78 0 ▶sub body { return $_[0]->_access_internal('body', $_[1]); }
Subroutine body: not called CC=1 SCAR=6.9
Pod documented
79 0 ▶sub delay { return $_[0]->_access_internal('delay', $_[1]); }
Subroutine delay: not called CC=1 SCAR=6.9
Pod documented
80 0 ▶sub push_headers { return $_[0]->_access_internal('push_headers', $_[1]); }
Subroutine push_headers: not called CC=1 SCAR=6.9
Pod documented
81 0 ▶sub id { return $_[0]->_access_internal('id', $_[1]); }
Subroutine id: not called CC=1 SCAR=6.9
Pod documented
82 0 ▶sub reserved_count { return $_[0]->_access_internal('reserved_count', $_[1]); }
Subroutine reserved_count: not called CC=1 SCAR=6.9
Pod documented
83 0 ▶sub reservation_id { return $_[0]->_access_internal('reservation_id', $_[1]); }
Subroutine reservation_id: not called CC=1 SCAR=6.9
Pod documented
84  
85 # TODO Move _access_internal() to IO::Iron::Common.
86  
87 sub _access_internal {
88 0 ▶ my ($self, $var_name, $var_value) = @_;
Subroutine _access_internal: not called CC=2 SCAR=17.9
89 0 $log->tracef('_access_internal(%s, %s)', $var_name, $var_value);
90 0 ▶ if( defined $var_value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $var_value) { } 0 0 0
91 0 $self->{$var_name} = $var_value;
92 0 return $self;
93 }
94 else {
95 0 return $self->{$var_name};
96 }
97 }
98  
99 3 1;
100  
101 __END__
« blib/lib/IO/Iron/IronMQ/Client.pm ↑ Summary blib/lib/IO/Iron/PolicyBase.pm »