| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Class::Meta::Types::String; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Class::Meta::Types::String - String data types |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package MyApp::Thingy; |
|
10
|
|
|
|
|
|
|
use strict; |
|
11
|
|
|
|
|
|
|
use Class::Meta; |
|
12
|
|
|
|
|
|
|
use Class::Meta::Types::String; |
|
13
|
|
|
|
|
|
|
# OR... |
|
14
|
|
|
|
|
|
|
# use Class::Meta::Types::String 'affordance'; |
|
15
|
|
|
|
|
|
|
# OR... |
|
16
|
|
|
|
|
|
|
# use Class::Meta::Types::String 'semi-affordance'; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
BEGIN { |
|
19
|
|
|
|
|
|
|
# Create a Class::Meta object for this class. |
|
20
|
|
|
|
|
|
|
my $cm = Class::Meta->new( key => 'thingy' ); |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# Add a string attribute. |
|
23
|
|
|
|
|
|
|
$cm->add_attribute( name => 'name', |
|
24
|
|
|
|
|
|
|
type => 'string' ); |
|
25
|
|
|
|
|
|
|
$cm->build; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
This module provides a string data type for use with Class::Meta attributes. |
|
31
|
|
|
|
|
|
|
Simply load it, then pass "string" to the C method of a |
|
32
|
|
|
|
|
|
|
Class::Meta object to create an attribute of the string data type. See |
|
33
|
|
|
|
|
|
|
L for more information on using and |
|
34
|
|
|
|
|
|
|
creating data types. |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
|
37
|
|
|
|
|
|
|
|
|
38
|
17
|
|
|
17
|
|
36059
|
use strict; |
|
|
17
|
|
|
|
|
39
|
|
|
|
17
|
|
|
|
|
637
|
|
|
39
|
17
|
|
|
17
|
|
106
|
use Class::Meta::Type; |
|
|
17
|
|
|
|
|
34
|
|
|
|
17
|
|
|
|
|
3029
|
|
|
40
|
|
|
|
|
|
|
our $VERSION = '0.66'; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub import { |
|
43
|
17
|
|
|
17
|
|
147
|
my ($pkg, $builder) = @_; |
|
44
|
17
|
|
100
|
|
|
110
|
$builder ||= 'default'; |
|
45
|
17
|
50
|
|
|
|
1113
|
return if eval "Class::Meta::Type->new('string')"; |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Class::Meta::Type->add( |
|
48
|
|
|
|
|
|
|
key => "string", |
|
49
|
|
|
|
|
|
|
name => "String", |
|
50
|
|
|
|
|
|
|
desc => "String", |
|
51
|
|
|
|
|
|
|
builder => $builder, |
|
52
|
|
|
|
|
|
|
check => sub { |
|
53
|
107
|
100
|
66
|
107
|
|
973
|
return unless defined $_[0] && ref $_[0]; |
|
54
|
7
|
|
|
|
|
57
|
$_[2]->class->handle_error("Value '$_[0]' is not a valid string"); |
|
55
|
|
|
|
|
|
|
} |
|
56
|
17
|
|
|
|
|
157
|
); |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
|
60
|
|
|
|
|
|
|
__END__ |