App/Chart/Gtk2/Ex/TreePath/Subclass.pm untested

filter: Statementstmt 0.0% 0 / 26 Branchbran n/a Conditioncond 0.0% 0 / 2 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 40 CC 1 SCAR 6.9
CC
1
Cov
0%
new
2.0
new_first
2.0
new_from_indices
2.0
CRAP 2.0
1 # Copyright 2007, 2008, 2009, 2010, 2011 Kevin Ryde
2  
3 # This file is part of Chart.
4 #
5 # Chart is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 3, or (at your option) any later
8 # version.
9 #
10 # Chart is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 # for more details.
14 #
15 # You should have received a copy of the GNU General Public License along
16 # with Chart. If not, see <http://www.gnu.org/licenses/>.
17  
18 package App::Chart::Gtk2::Ex::TreePath::Subclass;
19 use 5.008;
20 use strict;
21 use warnings;
22 use Gtk2;
23  
24 # not "use base 'Gtk2::TreePath'" here because base.pm complains that
25 # Gtk2::TreePath is empty -- until it's autoloaded or something, presumably
26 our @ISA = ('Gtk2::TreePath');
27  
28 sub new {
29 my $class = shift;
30 my $self = $class->SUPER::new (@_);
31 return bless $self, $class; # rebless
32 }
33 sub new_first {
34 my $class = shift;
35 my $self = $class->SUPER::new_first (@_);
36 return bless $self, $class; # rebless
37 }
38 sub new_from_indices {
39 my $class = shift;
40 my $self = $class->SUPER::new_from_indices (@_);
41 return bless $self, $class; # rebless
42 }
43 sub new_from_string {
44 my $class = shift;
45 my $self = $class->SUPER::new_from_string (@_);
46 # can return undef if string is bad
47 return $self && bless $self, $class; # rebless
48 }
49  
50  
51 1;
52 __END__
53  
54 =for stopwords TreePath reblessing subclassing subclasses Gtk2-Perl Ryde multi-inheritance Gtk
55  
56 =head1 NAME
57  
58 App::Chart::Gtk2::Ex::TreePath::Subclass -- TreePath constructors with reblessing
59  
60 =head1 SYNOPSIS
61  
62 package My::TreePath::Variant;
63 use App::Chart::Gtk2::Ex::TreePath::Subclass;
64 our @ISA = ('App::Chart::Gtk2::Ex::TreePath::Subclass', 'Gtk2::TreePath');
65 # ...
66  
67 package main;
68 my $path = My::TreePath::Variant->new;
69  
70 =head1 DESCRIPTION
71  
72 C<App::Chart::Gtk2::Ex::TreePath::Subclass> helps making Perl subclasses of
73 C<Gtk2::TreePath>. It provides versions of the following C<Gtk2::TreePath>
74 constructors
75  
76 new()
77 new_first()
78 new_from_indices()
79 new_from_string()
80  
81 They're designed as a multi-inheritance mix-in to override the corresponding
82 base methods in C<Gtk2::TreePath>. They re-bless the created object into
83 the class name given in the call, which is what you want when subclassing,
84 and which the C<Gtk2::TreePath> functions don't do (as of Gtk2-Perl version
85 1.223).
86  
87 Note that such re-blessing is only a Perl level subclass and so won't be
88 seen if the path object is returned back from some Gtk function, they'll
89 give back only plain C<Gtk2::TreePath>.
90  
91 =head1 SEE ALSO
92  
93 L<Gtk2::TreePath>
94  
95 =head1 HOME PAGE
96  
97 L<http://user42.tuxfamily.org/chart/index.html>
98  
99 =head1 LICENCE
100  
101 Copyright 2007, 2008, 2009, 2010, 2011 Kevin Ryde
102  
103 Chart is free software; you can redistribute it and/or modify it under the
104 terms of the GNU General Public License as published by the Free Software
105 Foundation; either version 3, or (at your option) any later version.
106  
107 Chart is distributed in the hope that it will be useful, but WITHOUT ANY
108 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
109 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
110 details.
111  
112 You should have received a copy of the GNU General Public License along with
113 Chart; see the file F<COPYING>. Failing that, see
114 L<http://www.gnu.org/licenses/>.
115  
116 =cut