File Coverage

blib/lib/Protocol/FIX/MessageInstance.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod 4 4 100.0
total 22 22 100.0


line stmt bran cond sub pod time code
1             package Protocol::FIX::MessageInstance;
2              
3 11     11   75 use strict;
  11         22  
  11         296  
4 11     11   54 use warnings;
  11         23  
  11         1817  
5              
6             our $VERSION = '0.07'; ## VERSION
7              
8             =head1 NAME
9              
10             Protocol::FIX::MessageInstance - handy accessor for deserialized FIX message
11              
12             =cut
13              
14             =head1 METHODS
15              
16             =head3 new
17              
18             new($class, $message, $tags_accessor)
19              
20             Creates new Message Instance (performed by Parser)
21              
22             =cut
23              
24             sub new {
25 12     12 1 37 my ($class, $message, $tags_accessor) = @_;
26             my $obj = {
27             name => $message->{name},
28             category => $message->{category},
29 12         57 tags_accessor => $tags_accessor,
30             };
31 12         62 return bless $obj, $class;
32             }
33              
34             =head3 value
35              
36             value($self, $name)
37              
38             Tiny wrapper of tag-accessors for direcly accessed message fileds.
39              
40             If C<$name> refers to field, then it returns field value.
41              
42             If C<$name> refers to component, it returns L,
43             where C method can me invoked, i.e.
44              
45             $mi->value('Component')->value('Field')
46              
47             If C<$name> refers to (repetitive) group, then it returns
48             array of Ls, i.e.
49              
50             $mi->value('Group')->[0]->value('Field')
51              
52             If field/component/group are not found in stream, or
53             are not direclty available in message definition, C
54             will be returned.
55              
56             =cut
57              
58             sub value {
59 39     39 1 2658 return shift->{tags_accessor}->value(shift);
60             }
61              
62             =head3 name
63              
64             name($self, $name)
65              
66             Returns message name, e.g. C
67              
68             =cut
69              
70 6     6 1 4324 sub name { return shift->{name} }
71              
72             =head3 category
73              
74             category($self, $name)
75              
76             Returns message category, e.g. C or C
77              
78             =cut
79              
80 6     6 1 29 sub category { return shift->{category} }
81              
82             1;