File Coverage

blib/lib/Glib/Ex/ObjectBits.pm
Criterion Covered Total %
statement 15 23 65.2
branch 0 4 0.0
condition n/a
subroutine 5 6 83.3
pod 1 1 100.0
total 21 34 61.7


line stmt bran cond sub pod time code
1             # Copyright 2010, 2011, 2012, 2014 Kevin Ryde
2              
3             # This file is part of Glib-Ex-ObjectBits.
4             #
5             # Glib-Ex-ObjectBits is free software; you can redistribute it and/or modify
6             # it under the terms of the GNU General Public License as published by the
7             # Free Software Foundation; either version 3, or (at your option) any later
8             # version.
9             #
10             # Glib-Ex-ObjectBits is distributed in the hope that it will be useful, but
11             # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12             # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13             # for more details.
14             #
15             # You should have received a copy of the GNU General Public License along
16             # with Glib-Ex-ObjectBits. If not, see .
17              
18             package Glib::Ex::ObjectBits;
19 1     1   26404 use 5.008;
  1         4  
  1         33  
20 1     1   5 use strict;
  1         1  
  1         43  
21 1     1   4 use warnings;
  1         3  
  1         31  
22 1     1   5 use Carp;
  1         1  
  1         82  
23              
24             # uncomment this to run the ### lines
25             #use Smart::Comments;
26              
27 1     1   5 use Exporter;
  1         2  
  1         186  
28             our @ISA = ('Exporter');
29             our @EXPORT_OK = qw(set_property_maybe);
30              
31             our $VERSION = 16;
32              
33             sub set_property_maybe {
34 0     0 1   my $object = shift;
35 0 0         if (@_ & 1) {
36 0           croak "set_property_maybe() expect even number of pname,value arguments";
37             }
38 0           for (my $i = 0; $i < @_; ) {
39             ### set_property_maybe(): $_[$i]
40             ### pspec(): $object->find_property($_[$i])
41 0 0         if ($object->find_property($_[$i])) {
42 0           $i += 2;
43             } else {
44 0           splice @_, $i, 2;
45             }
46             }
47 0           $object->set_property (@_);
48             }
49              
50             1;
51             __END__