File Coverage

blib/lib/WebService/Cmis/Property/Boolean.pm
Criterion Covered Total %
statement 9 23 39.1
branch 0 12 0.0
condition 0 3 0.0
subroutine 3 5 60.0
pod 2 2 100.0
total 14 45 31.1


line stmt bran cond sub pod time code
1             package WebService::Cmis::Property::Boolean;
2              
3             =head1 NAME
4              
5             WebService::Cmis::Property::Boolean
6              
7             Representation of a propertyBoolean of a cmis object
8              
9             =head1 SYNOPSIS
10              
11             =head1 DESCRIPTION
12              
13             =cut
14              
15 1     1   7416 use strict;
  1         2  
  1         41  
16 1     1   6 use warnings;
  1         3  
  1         29  
17 1     1   6 use WebService::Cmis::Property ();
  1         2  
  1         279  
18             our @ISA = qw(WebService::Cmis::Property);
19              
20             =head1 METHODS
21              
22             =over 4
23              
24             =item parse($cmisValue) -> $perlValue
25              
26             static helper to convert the given string into its perl representation
27              
28             =cut
29              
30             sub parse {
31 0     0 1   my ($this, $value) = @_;
32              
33 0 0         return 0 unless defined $value;
34              
35 0           $value =~ s/^\s+//;
36 0           $value =~ s/\s+$//;
37 0           $value =~ s/off//gi;
38 0           $value =~ s/no//gi;
39 0           $value =~ s/false//gi;
40              
41 0 0         return ($value) ? 1 : 0;
42             }
43              
44             =item unparse($perlValue) $cmisValue
45              
46             converts a perl representation back to a format understood by cmis
47              
48             =cut
49              
50             sub unparse {
51 0     0 1   my ($this, $value) = @_;
52              
53             #print STDERR "this=$this, value=$value, ref(this)=".ref($this)."\n";
54 0 0 0       $value = $this->{value} if ref($this) && ! defined $value;
55              
56 0 0         return 'none' unless defined $value;
57 0 0         return 'false' if $value eq '0';
58 0 0         return 'true' if $value eq '1';
59 0           return $value;
60             }
61              
62             =back
63              
64             =head1 COPYRIGHT AND LICENSE
65              
66             Copyright 2012-2013 Michael Daum
67              
68             This module is free software; you can redistribute it and/or modify it under
69             the same terms as Perl itself. See F.
70              
71             =cut
72              
73             1;