1
package Class::Meta::Types::Perl;
3
# $Id: Perl.pm 2405 2005-12-17 03:41:09Z theory $
7
Class::Meta::Types::Perl - Perl data types
11
package MyApp::Thingy;
14
use Class::Meta::Types::Perl;
16
# use Class::Meta::Types::Perl 'affordance';
18
# use Class::Meta::Types::Perl 'semi-affordance';
21
# Create a Class::Meta object for this class.
22
my $cm = Class::Meta->new( key => 'thingy' );
24
# Add an integer attribute.
25
$cm->add_attribute( name => 'my_hash',
32
This module provides Perl data types for use with Class::Meta attributes.
33
Simply load it, then pass the name of one of its types to the
34
C<add_attribute()> method of a Class::Meta object. See
35
L<Class::Meta::Type|Class::Meta::Type> for more information on using and
38
The validation checks for Class::Meta::Types::Perl are provided by the
39
Class::Meta::Type's support for object type validation, since Perl data types
40
are understood by C<UNIVERSAL::isa()>.
42
The data types created by Class::Meta::Types::Perl are:
48
A simple scalar value. This can be anything, and has no validation checks.
52
A scalar reference. C<UNIVERSAL::isa()> must return 'SCALAR'.
58
A array reference. C<UNIVERSAL::isa()> must return 'ARRAY'.
64
A hash reference. C<UNIVERSAL::isa()> must return 'HASH'.
72
A code reference. Also known as a closure. C<UNIVERSAL::isa()> must return
80
use Class::Meta::Type;
81
our $VERSION = "0.52";
84
my ($pkg, $builder) = @_;
85
$builder ||= 'default';
86
return if eval "Class::Meta::Type->new('array')";
88
Class::Meta::Type->add(
95
Class::Meta::Type->add(
97
name => "Scalar Reference",
98
desc => "Scalar reference",
103
Class::Meta::Type->add(
105
name => "Array Reference",
106
desc => "Array reference",
112
Class::Meta::Type->add(
114
name => "Hash Reference",
115
desc => "Hash reference",
121
Class::Meta::Type->add(
123
name => "Code Reference",
124
desc => "Code reference",
125
alias => [qw(coderef closure)],
136
Please send bug reports to <bug-class-meta@rt.cpan.org> or report them via the
137
CPAN Request Tracker at L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Class-Meta>.
141
David Wheeler <david@kineticode.com>
145
Other classes of interest within the Class::Meta distribution include:
149
=item L<Class::Meta|Class::Meta>
151
This class contains most of the documentation you need to get started with
154
=item L<Class::Meta::Type|Class::Meta::Type>
156
This class manages the creation of data types.
158
=item L<Class::Meta::Attribute|Class::Meta::Attribute>
160
This class manages Class::Meta class attributes, all of which are based on
165
Other data type modules:
169
=item L<Class::Meta::Types::String|Class::Meta::Types::String>
171
=item L<Class::Meta::Types::Boolean|Class::Meta::Types::Boolean>
173
=item L<Class::Meta::Types::Numeric|Class::Meta::Types::Numeric>
177
=head1 COPYRIGHT AND LICENSE
179
Copyright (c) 2002-2005, David Wheeler. All Rights Reserved.
181
This module is free software; you can redistribute it and/or modify it under
182
the same terms as Perl itself.