line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Venus::Role::Boxable; |
2
|
|
|
|
|
|
|
|
3
|
87
|
|
|
87
|
|
1542
|
use 5.018; |
|
87
|
|
|
|
|
354
|
|
4
|
|
|
|
|
|
|
|
5
|
87
|
|
|
87
|
|
458
|
use strict; |
|
87
|
|
|
|
|
156
|
|
|
87
|
|
|
|
|
1734
|
|
6
|
87
|
|
|
87
|
|
386
|
use warnings; |
|
87
|
|
|
|
|
182
|
|
|
87
|
|
|
|
|
2288
|
|
7
|
|
|
|
|
|
|
|
8
|
87
|
|
|
87
|
|
39022
|
use Venus::Role 'with'; |
|
87
|
|
|
|
|
240
|
|
|
87
|
|
|
|
|
572
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# METHODS |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub box { |
13
|
2
|
|
|
2
|
1
|
18
|
my ($self, $method, @args) = @_; |
14
|
|
|
|
|
|
|
|
15
|
2
|
|
|
|
|
542
|
require Venus::Box; |
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
|
|
6
|
local $_ = $self; |
18
|
|
|
|
|
|
|
|
19
|
2
|
100
|
|
|
|
12
|
my $value = $method ? $self->$method(@args) : $self; |
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
|
|
15
|
return Venus::Box->new(value => $value); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# EXPORTS |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub EXPORT { |
27
|
88
|
|
|
88
|
0
|
296
|
['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(Str | CodeRef $method, Any @args) (Self) |
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, Al Newkirk. |
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 |