File Coverage

blib/lib/Thrift/Parser/Field.pm
Criterion Covered Total %
statement 16 16 100.0
branch n/a
condition 1 2 50.0
subroutine 5 5 100.0
pod 0 2 0.0
total 22 25 88.0


line stmt bran cond sub pod time code
1             package Thrift::Parser::Field;
2              
3             =head1 NAME
4              
5             Thrift::Parser::Field - A single field in a structure
6              
7             =cut
8              
9 6     6   35 use strict;
  6         12  
  6         207  
10 6     6   34 use warnings;
  6         13  
  6         184  
11 6     6   32 use base qw(Class::Accessor::Grouped);
  6         11  
  6         1268  
12             __PACKAGE__->mk_group_accessors(inherited => qw(id name value));
13              
14             =head1 USAGE
15              
16             =head2 id
17              
18             Returns the id of this field in the structure.
19              
20             =head2 name
21              
22             Returns the name of the field.
23              
24             =head2 value
25              
26             Returns the L object representing the value of this field.
27              
28             =cut
29              
30             sub new {
31 13     13 0 266 my ($class, $self) = @_;
32 13   50     43 $self ||= {};
33 13         77 return bless $self, $class;
34             }
35              
36             sub write {
37 2     2 0 5 my ($self, $output) = @_;
38              
39 2         61 $output->writeFieldBegin($self->name, $self->value->type_id, $self->id);
40 2         67 $self->value->write($output);
41 2         8 $output->writeFieldEnd();
42             }
43              
44             =head1 COPYRIGHT
45              
46             Copyright (c) 2009 Eric Waters and XMission LLC (http://www.xmission.com/). All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
47              
48             The full text of the license can be found in the LICENSE file included with this module.
49              
50             =head1 AUTHOR
51              
52             Eric Waters
53              
54             =cut
55              
56             1;