File: Element.pm

package info (click to toggle)
libowl-directsemantics-perl 0.001-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 664 kB
  • sloc: perl: 5,519; makefile: 7; sh: 1
file content (104 lines) | stat: -rw-r--r-- 1,821 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package OWL::DirectSemantics::Element;

BEGIN {
	$OWL::DirectSemantics::Element::AUTHORITY = 'cpan:TOBYINK';
	$OWL::DirectSemantics::Element::VERSION   = '0.001';
};




use Moose;

has 'annotations' => (
	is         => 'rw',
	isa        => 'ArrayRef',
	auto_deref => 1,
	default    => sub{[]},
	traits     => ['Array'],
	handles    => { add_annotation => 'push' },
	);

has 'metadata' => (
	is         => 'rw',
	isa        => 'HashRef',
	);

sub element_name
{
	my ($proto) = @_;
	$proto = ref($proto) if ref($proto);
	return $1 if $proto =~ /^OWL::DirectSemantics::Element::(.+)$/;
	return;
}

1;

__END__

=head1 NAME

OWL::DirectSemantics::Element - base class for OWL elements.

=head1 DESCRIPTION

This could porssibly be refactored into a Moose::Role - not sure yet.

=head2 Constructor

=over

=item C<< new(%attributes) >>

Don't construct this base class directly. Constract a subclass instead.

=back

=head2 Attributes

=over

=item C<< annotations >>

A list of annotations associated with this object.
The value is a ArrayRef.

=item C<< metadata >>

This metadata may be used by Writers, etc if available.

=back

=head2 Method

=over

=item C<< element_name >>

Returns undef on the base class or any abstract subclasses. Returns the
element name (e.g. 'ClassAssertion' or 'Declaration') on other subclasses.

=back

=head1 SEE ALSO

L<OWL::DirectSemantics>.

=head1 AUTHOR

Toby Inkster E<lt>tobyink@cpan.orgE<gt>.

=head1 COPYRIGHT

Copyright 2011-2012 Toby Inkster

This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

=head1 DISCLAIMER OF WARRANTIES

THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.