File Coverage

blib/lib/Net/PMP/CollectionDoc/Permission.pm
Criterion Covered Total %
statement 12 18 66.6
branch 0 4 0.0
condition n/a
subroutine 4 5 80.0
pod 1 1 100.0
total 17 28 60.7


line stmt bran cond sub pod time code
1             package Net::PMP::CollectionDoc::Permission;
2 3     3   18 use Moose;
  3         6  
  3         18  
3 3     3   11796 use Carp;
  3         6  
  3         185  
4 3     3   17 use Data::Dump qw( dump );
  3         5  
  3         107  
5 3     3   15 use Net::PMP::TypeConstraints;
  3         7  
  3         411  
6              
7             our $VERSION = '0.006';
8              
9             has 'href' => ( is => 'rw', isa => 'Net::PMP::Type::Href', required => 1, );
10             has 'operation' => (
11             is => 'rw',
12             isa => Moose::Util::TypeConstraints::enum( [qw( read write )] ),
13             default => 'read',
14             required => 1,
15             );
16             has 'blacklist' => ( is => 'rw', isa => 'Bool' );
17              
18             sub as_hash {
19 0     0 1   my $self = shift;
20 0           my $hash = { %{$self} };
  0            
21 0 0         if ( exists $hash->{blacklist} ) {
22 0 0         $hash->{blacklist} = $hash->{blacklist} ? \1 : \0;
23             }
24 0           return $hash;
25             }
26              
27             __PACKAGE__->meta->make_immutable();
28              
29             1;
30              
31             __END__
32              
33             =head1 NAME
34              
35             Net::PMP::CollectionDoc::Permission - permission link type from a Net::PMP::CollectionDoc::Links object
36              
37             =head1 SYNOPSIS
38              
39             my $permission = Net::PMP::CollectionDoc::Permission->new(
40             href => 'https://api.pmp.io/docs/some-guid-for-some-group',
41             operation => 'read',
42             blacklist => 1,
43             );
44             $doc->links->{permission} = [ $permission ];
45              
46             =head1 DESCRIPTION
47              
48             Net::PMP::CollectionDoc::Permission represents a special link in a Collection.doc+JSON PMP API response.
49             See L<https://github.com/publicmediaplatform/pmpdocs/wiki/Permissions-Design>.
50              
51             =head1 METHODS
52              
53             =head2 href
54              
55             =head2 operation
56              
57             Either C<write> or C<read>.
58              
59             =head2 blacklist
60              
61             Boolean (true or false).
62              
63             =head2 as_hash
64              
65             Returns object as Perl hashref. The blacklist() value, if set, will be output as a scalar
66             reference to an integer, so that passing to encode_json() will create a proper JSON boolean.
67              
68             =head1 AUTHOR
69              
70             Peter Karman, C<< <karman at cpan.org> >>
71              
72             =head1 BUGS
73              
74             Please report any bugs or feature requests to C<bug-net-pmp at rt.cpan.org>, or through
75             the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-PMP>. I will be notified, and then you'll
76             automatically be notified of progress on your bug as I make changes.
77              
78              
79             =head1 SUPPORT
80              
81             You can find documentation for this module with the perldoc command.
82              
83             perldoc Net::PMP::CollectionDoc::Link
84              
85              
86             You can also look for information at:
87              
88             =over 4
89              
90             =item * RT: CPAN's request tracker (report bugs here)
91              
92             L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-PMP>
93              
94             =item * AnnoCPAN: Annotated CPAN documentation
95              
96             L<http://annocpan.org/dist/Net-PMP>
97              
98             =item * CPAN Ratings
99              
100             L<http://cpanratings.perl.org/d/Net-PMP>
101              
102             =item * Search CPAN
103              
104             L<http://search.cpan.org/dist/Net-PMP/>
105              
106             =back
107              
108              
109             =head1 ACKNOWLEDGEMENTS
110              
111             American Public Media and the Public Media Platform sponsored the development of this module.
112              
113             =head1 LICENSE AND COPYRIGHT
114              
115             Copyright 2013 American Public Media Group
116              
117             See the LICENSE file that accompanies this module.
118              
119             =cut