line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::MakeMethods::Template::Scalar; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
18030
|
use Class::MakeMethods::Template::Generic '-isasubclass'; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
49
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
$VERSION = 1.008; |
6
|
4
|
|
|
4
|
|
29
|
use strict; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
230
|
|
7
|
|
|
|
|
|
|
require 5.00; |
8
|
4
|
|
|
4
|
|
22
|
use Carp; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
701
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Class::MakeMethods::Template::Scalar - Methods for blessed scalars |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 SYNOPSIS |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
package MyObject; |
17
|
|
|
|
|
|
|
use Class::MakeMethods::Template::ExternalData ( |
18
|
|
|
|
|
|
|
new => 'new', |
19
|
|
|
|
|
|
|
scalar => 'foo', |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
package main; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $obj = MyObject->new( foo => "Foozle" ); |
25
|
|
|
|
|
|
|
print $obj->foo(); # Prints Foozle |
26
|
|
|
|
|
|
|
$obj->foo("Bamboozle"); # Sets $$obj |
27
|
|
|
|
|
|
|
print $obj->foo(); # Prints Bamboozle |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 DESCRIPTION |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Supports the Generic object constructor and accessors meta-method |
32
|
|
|
|
|
|
|
types, but uses scalar refs as the underlying implementation type, |
33
|
|
|
|
|
|
|
so only one accessor method can be used effectively. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub generic { |
38
|
|
|
|
|
|
|
{ |
39
|
4
|
|
|
4
|
0
|
175
|
'-import' => { |
40
|
|
|
|
|
|
|
'Template::Generic:generic' => '*' |
41
|
|
|
|
|
|
|
}, |
42
|
|
|
|
|
|
|
'code_expr' => { |
43
|
|
|
|
|
|
|
_VALUE_ => '(${_SELF_})', |
44
|
|
|
|
|
|
|
_EMPTY_NEW_INSTANCE_ => 'bless \( my $scalar = undef ), _SELF_CLASS_', |
45
|
|
|
|
|
|
|
}, |
46
|
|
|
|
|
|
|
'params' => { |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
######################################################################## |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 Standard Methods |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
The following methods from Generic are all supported: |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
new |
58
|
|
|
|
|
|
|
scalar |
59
|
|
|
|
|
|
|
string |
60
|
|
|
|
|
|
|
string_index |
61
|
|
|
|
|
|
|
number |
62
|
|
|
|
|
|
|
boolean |
63
|
|
|
|
|
|
|
bits |
64
|
|
|
|
|
|
|
array |
65
|
|
|
|
|
|
|
hash |
66
|
|
|
|
|
|
|
tiedhash |
67
|
|
|
|
|
|
|
hash_of_arrays |
68
|
|
|
|
|
|
|
object |
69
|
|
|
|
|
|
|
instance |
70
|
|
|
|
|
|
|
array_of_objects |
71
|
|
|
|
|
|
|
code |
72
|
|
|
|
|
|
|
code_or_scalar |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
See L for the interfaces and behaviors of these method types. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
However, note that due to special nature of this package, all accessor methods reference the same scalar value, so setting a value with one method will overwrite the value retrieved by another. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |