File Coverage

blib/lib/ODO/Ontology/ObjectWriter/Package.pm
Criterion Covered Total %
statement 12 23 52.1
branch 0 6 0.0
condition n/a
subroutine 4 6 66.6
pod 2 2 100.0
total 18 37 48.6


line stmt bran cond sub pod time code
1             #
2             # Copyright (c) 2006 IBM Corporation.
3             #
4             # All rights reserved. This program and the accompanying materials
5             # are made available under the terms of the Eclipse Public License v1.0
6             # which accompanies this distribution, and is available at
7             # http://www.eclipse.org/legal/epl-v10.html
8             #
9             # File: $Source: /var/lib/cvs/ODO/lib/ODO/Ontology/ObjectWriter/Package.pm,v $
10             # Created by: Stephen Evanchik( evanchik@us.ibm.com )
11             # Created on: 11/28/2006
12             # Revision: $Id: Package.pm,v 1.2 2009-11-25 17:58:26 ubuntu Exp $
13             #
14             # Contributors:
15             # IBM Corporation - initial API and implementation
16             #
17             package ODO::Ontology::ObjectWriter::Package;
18              
19 2     2   12 use strict;
  2         4  
  2         70  
20 2     2   11 use warnings;
  2         3  
  2         62  
21              
22 2     2   10 use base qw/ODO::Ontology::ObjectWriter/;
  2         5  
  2         279  
23              
24 2     2   11 use vars qw /$VERSION/;
  2         5  
  2         600  
25             $VERSION = sprintf "%d.%02d", q$Revision: 1.2 $ =~ /: (\d+)\.(\d+)/;
26              
27             our @METHODS = qw/inheritanceMap constructor properties packageName useModules ISA variables varDeclarations baseClasses/;
28              
29             __PACKAGE__->mk_accessors(@METHODS);
30              
31             =head1 NAME
32              
33             =head1 SYNOPSIS
34              
35             =head1 DESCRIPTION
36              
37             =head1 CONSTRUCTOR
38              
39             =head1 METHODS
40              
41             =over
42              
43             =item serialize( [ %parameters ] )
44              
45             =cut
46              
47             sub serialize {
48 0     0 1   my $self = shift;
49              
50             # Build the Class definition
51 0           my $class_data = {
52             packageName=> $self->packageName(),
53             useModules=> $self->useModules(),
54             variables=> $self->variables(),
55             ISA=> $self->ISA(),
56             varDeclarations=> $self->varDeclarations(),
57             baseClasses=> $self->baseClasses(),
58             constructor=> $self->constructor()->serialize(),
59             };
60              
61 0           return $self->ODO::Ontology::ObjectWriter::serialize(template_data=> $class_data, @_);
62             }
63              
64              
65             sub init {
66 0     0 1   my ($self, $config) = @_;
67 0           $self = $self->SUPER::init($config);
68              
69 0 0         throw ODO::Exception::Parameter::Missing(error=> 'Missing parameter: \'constructor\'')
70             unless(defined($config->{'constructor'}));
71            
72 0           $self->params($config, @METHODS);
73            
74             # Borrow the properties from the constructor object
75             # unless they are already present
76 0 0         unless(defined($config->{'properties'})) {
77 0           $self->properties($self->constructor()->properties());
78             }
79            
80 0 0         $self->template_filename('ODO/Ontology/Templates/Package.tt')
81             unless(exists($config->{'template_filename'}));
82              
83 0           return $self;
84             }
85              
86              
87             1;
88              
89             __END__