line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Venus::Role::Boxable; |
2
|
|
|
|
|
|
|
|
3
|
96
|
|
|
96
|
|
1743
|
use 5.018; |
|
96
|
|
|
|
|
324
|
|
4
|
|
|
|
|
|
|
|
5
|
96
|
|
|
96
|
|
508
|
use strict; |
|
96
|
|
|
|
|
198
|
|
|
96
|
|
|
|
|
1947
|
|
6
|
96
|
|
|
96
|
|
453
|
use warnings; |
|
96
|
|
|
|
|
201
|
|
|
96
|
|
|
|
|
2960
|
|
7
|
|
|
|
|
|
|
|
8
|
96
|
|
|
96
|
|
43935
|
use Venus::Role 'with'; |
|
96
|
|
|
|
|
268
|
|
|
96
|
|
|
|
|
686
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# METHODS |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub box { |
13
|
2
|
|
|
2
|
1
|
11
|
my ($self, $method, @args) = @_; |
14
|
|
|
|
|
|
|
|
15
|
2
|
|
|
|
|
537
|
require Venus::Box; |
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
|
|
19
|
local $_ = $self; |
18
|
|
|
|
|
|
|
|
19
|
2
|
100
|
|
|
|
11
|
my $value = $method ? $self->$method(@args) : $self; |
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
|
|
10
|
return Venus::Box->new(value => $value); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# EXPORTS |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub EXPORT { |
27
|
97
|
|
|
97
|
0
|
340
|
['box'] |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
1; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 NAME |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Venus::Role::Boxable - Boxable Role |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=cut |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 ABSTRACT |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Boxable Role for Perl 5 |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 SYNOPSIS |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
package Example; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
use Venus::Class; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
with 'Venus::Role::Boxable'; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
attr 'text'; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
package main; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my $example = Example->new(text => 'hello, world'); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# $example->box('text')->lc->ucfirst->concat('.')->unbox->get; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# "Hello, world." |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 DESCRIPTION |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
This package modifies the consuming package and provides a method for boxing |
69
|
|
|
|
|
|
|
itself. This makes it possible to chain method calls across objects and values. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 METHODS |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
This package provides the following methods: |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 box |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
box(string | coderef $method, any @args) (object) |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
The box method returns the invocant boxed, i.e. encapsulated, using |
84
|
|
|
|
|
|
|
L. This method supports dispatching, i.e. providing a method name |
85
|
|
|
|
|
|
|
and arguments whose return value will be acted on by this method. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
I> |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=over 4 |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item box example 1 |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
package main; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
my $example = Example->new(text => 'hello, world'); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
my $box = $example->box; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# bless({ value => bless(..., "Example") }, "Venus::Box") |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=back |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=over 4 |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item box example 2 |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
package main; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
my $example = Example->new(text => 'hello, world'); |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
my $box = $example->box('text'); |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
# bless({ value => bless(..., "Venus::String") }, "Venus::Box") |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
# $example->box('text')->lc->ucfirst->concat('.')->unbox->get; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=back |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=cut |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 AUTHORS |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Awncorp, C |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 LICENSE |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Copyright (C) 2000, Awncorp, C. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
This program is free software, you can redistribute it and/or modify it under |
132
|
|
|
|
|
|
|
the terms of the Apache license version 2.0. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=cut |