line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Rose::HTML::Object::Message; |
2
|
|
|
|
|
|
|
|
3
|
44
|
|
|
44
|
|
1024
|
use strict; |
|
44
|
|
|
|
|
95
|
|
|
44
|
|
|
|
|
1263
|
|
4
|
|
|
|
|
|
|
|
5
|
44
|
|
|
44
|
|
222
|
use Carp; |
|
44
|
|
|
|
|
104
|
|
|
44
|
|
|
|
|
2196
|
|
6
|
44
|
|
|
44
|
|
786
|
use Clone::PP; |
|
44
|
|
|
|
|
940
|
|
|
44
|
|
|
|
|
329
|
|
7
|
44
|
|
|
44
|
|
1847
|
use Scalar::Util(); |
|
44
|
|
|
|
|
110
|
|
|
44
|
|
|
|
|
1068
|
|
8
|
|
|
|
|
|
|
|
9
|
44
|
|
|
44
|
|
242
|
use Rose::HTML::Object::Messages qw(CUSTOM_MESSAGE); |
|
44
|
|
|
|
|
122
|
|
|
44
|
|
|
|
|
354
|
|
10
|
|
|
|
|
|
|
|
11
|
44
|
|
|
44
|
|
305
|
use base 'Rose::Object'; |
|
44
|
|
|
|
|
146
|
|
|
44
|
|
|
|
|
8724
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.606'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
#our $Debug = 0; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use overload |
18
|
|
|
|
|
|
|
( |
19
|
0
|
|
|
0
|
|
0
|
'""' => sub { shift->text }, |
20
|
0
|
|
|
0
|
|
0
|
'bool' => sub { 1 }, |
21
|
0
|
|
|
0
|
|
0
|
'0+' => sub { 1 }, |
22
|
44
|
|
|
|
|
655
|
fallback => 1, |
23
|
44
|
|
|
44
|
|
1894
|
); |
|
44
|
|
|
|
|
1131
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
use Rose::Object::MakeMethods::Generic |
26
|
|
|
|
|
|
|
( |
27
|
44
|
|
|
|
|
490
|
scalar => |
28
|
|
|
|
|
|
|
[ |
29
|
|
|
|
|
|
|
'id', |
30
|
|
|
|
|
|
|
'variant', |
31
|
|
|
|
|
|
|
], |
32
|
44
|
|
|
44
|
|
5471
|
); |
|
44
|
|
|
|
|
7275
|
|
33
|
|
|
|
|
|
|
|
34
|
44
|
|
|
44
|
0
|
29050
|
sub as_string { no warnings 'uninitialized'; "$_[0]" } |
|
44
|
|
|
12
|
|
132
|
|
|
44
|
|
|
|
|
26686
|
|
|
12
|
|
|
|
|
52
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub init |
37
|
|
|
|
|
|
|
{ |
38
|
856
|
|
|
856
|
1
|
42819
|
my($self) = shift; |
39
|
856
|
100
|
|
|
|
2121
|
@_ = (text => @_) if(@_ == 1); |
40
|
856
|
|
|
|
|
2604
|
$self->SUPER::init(@_); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub args |
44
|
|
|
|
|
|
|
{ |
45
|
2670
|
|
|
2670
|
0
|
9558
|
my($self) = shift; |
46
|
|
|
|
|
|
|
|
47
|
2670
|
100
|
|
|
|
5639
|
if(@_) |
48
|
|
|
|
|
|
|
{ |
49
|
459
|
|
|
|
|
727
|
my %args; |
50
|
|
|
|
|
|
|
|
51
|
459
|
100
|
66
|
|
|
2428
|
if(@_ == 1 && ref $_[0] eq 'ARRAY') |
|
|
50
|
33
|
|
|
|
|
52
|
|
|
|
|
|
|
{ |
53
|
400
|
|
|
|
|
775
|
my $i = 1; |
54
|
400
|
|
|
|
|
641
|
%args = (map { $i++ => $_ } @{$_[0]}); |
|
8
|
|
|
|
|
28
|
|
|
400
|
|
|
|
|
1013
|
|
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
elsif(@_ == 1 && ref $_[0] eq 'HASH') |
57
|
|
|
|
|
|
|
{ |
58
|
59
|
|
|
|
|
130
|
%args = %{$_[0]}; |
|
59
|
|
|
|
|
268
|
|
59
|
|
|
|
|
|
|
|
60
|
59
|
|
|
|
|
141
|
my $i = 1; |
61
|
|
|
|
|
|
|
|
62
|
59
|
|
|
|
|
290
|
foreach my $key (sort keys %args) |
63
|
|
|
|
|
|
|
{ |
64
|
84
|
50
|
|
|
|
283
|
$args{$i} = $args{$key} unless(exists $args{$i}); |
65
|
84
|
|
|
|
|
192
|
$i++; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
else |
69
|
|
|
|
|
|
|
{ |
70
|
0
|
|
|
|
|
0
|
my $i = 1; |
71
|
0
|
|
|
|
|
0
|
%args = map { $i++ => $_ } @_; |
|
0
|
|
|
|
|
0
|
|
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
459
|
|
|
|
|
1649
|
$self->{'args'} = \%args; |
75
|
|
|
|
|
|
|
|
76
|
459
|
50
|
|
|
|
1634
|
return wantarray ? %{$self->{'args'}} : $self->{'args'}; |
|
0
|
|
|
|
|
0
|
|
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
2211
|
0
|
100
|
|
|
10191
|
return wantarray ? %{$self->{'args'} || {}} : ($self->{'args'} ||= {}); |
|
0
|
50
|
|
|
|
0
|
|
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub parent |
83
|
|
|
|
|
|
|
{ |
84
|
8183
|
|
|
8183
|
0
|
15399
|
my($self) = shift; |
85
|
8183
|
100
|
|
|
|
18858
|
return Scalar::Util::weaken($self->{'parent'} = shift) if(@_); |
86
|
6982
|
|
|
|
|
18536
|
return $self->{'parent'}; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub clone |
90
|
|
|
|
|
|
|
{ |
91
|
0
|
|
|
0
|
0
|
0
|
my($self) = shift; |
92
|
0
|
|
|
|
|
0
|
my $clone = Clone::PP::clone($self); |
93
|
0
|
|
|
|
|
0
|
$clone->parent(undef); |
94
|
0
|
|
|
|
|
0
|
return $clone; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub text |
98
|
|
|
|
|
|
|
{ |
99
|
2258
|
|
|
2258
|
1
|
7217
|
my($self) = shift; |
100
|
|
|
|
|
|
|
|
101
|
2258
|
100
|
|
|
|
4837
|
if(@_) |
102
|
|
|
|
|
|
|
{ |
103
|
396
|
50
|
|
|
|
1562
|
if(UNIVERSAL::isa($_[0], __PACKAGE__)) |
104
|
|
|
|
|
|
|
{ |
105
|
0
|
|
|
|
|
0
|
$self->id($_[0]->id); |
106
|
0
|
|
|
|
|
0
|
return $self->{'text'} = $_[0]->text; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
396
|
|
|
|
|
1494
|
$self->id(CUSTOM_MESSAGE); |
110
|
396
|
|
|
|
|
2261
|
return $self->{'text'} = $_[0]; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
1862
|
|
|
|
|
12112
|
return $self->{'text'}; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
44
|
|
|
44
|
0
|
399
|
sub is_custom { no warnings; shift->id == CUSTOM_MESSAGE } |
|
44
|
|
|
2227
|
|
117
|
|
|
44
|
|
|
|
|
2851
|
|
|
2227
|
|
|
|
|
9144
|
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
1; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
__END__ |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 NAME |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Rose::HTML::Object::Message - Text message object. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 SYNOPSIS |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
$msg = Rose::HTML::Object::Message->new('Hello world'); |
129
|
|
|
|
|
|
|
print $msg->text; # Hello world |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 DESCRIPTION |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
L<Rose::HTML::Object::Message> objects encapsulate a text message with an optional integer L<id|/id>. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
This class inherits from, and follows the conventions of, L<Rose::Object>. See the L<Rose::Object> documentation for more information. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 OVERLOADING |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Stringification is overloaded to call the L<text|/text> method. In numeric and boolean contexts, L<Rose::HTML::Object::Message> objects always evaluate to true. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=over 4 |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=item B<new [ PARAMS | TEXT ]> |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Constructs a new L<Rose::HTML::Object::Message> object. If a single argument is passed, it is taken as the value for the L<text|/text> parameter. Otherwise, PARAMS name/value pairs are expected. Any object method is a valid parameter name. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=back |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 OBJECT METHODS |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=over 4 |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item B<id [INT]> |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Get or set the message's integer identifier. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=item B<text [ TEXT | OBJECT ]> |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Get or set the message's text. If the message text is set to a TEXT string (rather than a L<Rose::HTML::Object::Message>-derived OBJECT), the L<id|/id> is set to the value of the constant C<Rose::HTML::Object::Message::CUSTOM_MESSAGE>. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=back |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 AUTHOR |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
John C. Siracusa (siracusa@gmail.com) |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 LICENSE |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Copyright (c) 2010 by John C. Siracusa. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |