1TAP::Parser::ResultFactUosreyr(3C)ontributed Perl DocumeTnAtPa:t:iPoanrser::ResultFactory(3)
2
3
4

NAME

6       TAP::Parser::ResultFactory - Factory for creating TAP::Parser output
7       objects
8

SYNOPSIS

10         use TAP::Parser::ResultFactory;
11         my $token   = {...};
12         my $factory = TAP::Parser::ResultFactory->new;
13         my $result  = $factory->make_result( $token );
14

VERSION

16       Version 3.28
17
18   DESCRIPTION
19       This is a simple factory class which returns a TAP::Parser::Result
20       subclass representing the current bit of test data from TAP (usually a
21       single line).  It is used primarily by TAP::Parser::Grammar.  Unless
22       you're subclassing, you probably won't need to use this module
23       directly.
24
25   METHODS
26   Class Methods
27       "new"
28
29       Creates a new factory class.  Note: You currently don't need to
30       instantiate a factory in order to use it.
31
32       "make_result"
33
34       Returns an instance the appropriate class for the test token passed in.
35
36         my $result = TAP::Parser::ResultFactory->make_result($token);
37
38       Can also be called as an instance method.
39
40       "class_for"
41
42       Takes one argument: $type.  Returns the class for this $type, or
43       "croak"s with an error.
44
45       "register_type"
46
47       Takes two arguments: $type, $class
48
49       This lets you override an existing type with your own custom type, or
50       register a completely new type, eg:
51
52         # create a custom result type:
53         package MyResult;
54         use strict;
55         use vars qw(@ISA);
56         @ISA = 'TAP::Parser::Result';
57
58         # register with the factory:
59         TAP::Parser::ResultFactory->register_type( 'my_type' => __PACKAGE__ );
60
61         # use it:
62         my $r = TAP::Parser::ResultFactory->( { type => 'my_type' } );
63
64       Your custom type should then be picked up automatically by the
65       TAP::Parser.
66

SUBCLASSING

68       Please see "SUBCLASSING" in TAP::Parser for a subclassing overview.
69
70       There are a few things to bear in mind when creating your own
71       "ResultFactory":
72
73       1.  The factory itself is never instantiated (this may change in the
74           future).  This means that "_initialize" is never called.
75
76       2.  "TAP::Parser::Result->new" is never called, $tokens are reblessed.
77           This will change in a future version!
78
79       3.  TAP::Parser::Result subclasses will register themselves with
80           TAP::Parser::ResultFactory directly:
81
82             package MyFooResult;
83             TAP::Parser::ResultFactory->register_type( foo => __PACKAGE__ );
84
85           Of course, it's up to you to decide whether or not to ignore them.
86
87   Example
88         package MyResultFactory;
89
90         use strict;
91         use vars '@ISA';
92
93         use MyResult;
94         use TAP::Parser::ResultFactory;
95
96         @ISA = qw( TAP::Parser::ResultFactory );
97
98         # force all results to be 'MyResult'
99         sub class_for {
100           return 'MyResult';
101         }
102
103         1;
104

SEE ALSO

106       TAP::Parser, TAP::Parser::Result, TAP::Parser::Grammar
107
108
109
110perl v5.16.3                      2013-05-02     TAP::Parser::ResultFactory(3)
Impressum