line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Fey::Role::MakesAliasObjects; |
2
|
|
|
|
|
|
|
|
3
|
26
|
|
|
26
|
|
17049
|
use strict; |
|
26
|
|
|
|
|
54
|
|
|
26
|
|
|
|
|
1136
|
|
4
|
26
|
|
|
26
|
|
137
|
use warnings; |
|
26
|
|
|
|
|
48
|
|
|
26
|
|
|
|
|
817
|
|
5
|
26
|
|
|
26
|
|
145
|
use namespace::autoclean; |
|
26
|
|
|
|
|
45
|
|
|
26
|
|
|
|
|
209
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.43'; |
8
|
|
|
|
|
|
|
|
9
|
26
|
|
|
26
|
|
2544
|
use Fey::Types qw( ClassName Str ); |
|
26
|
|
|
|
|
47
|
|
|
26
|
|
|
|
|
224
|
|
10
|
|
|
|
|
|
|
|
11
|
26
|
|
|
26
|
|
124923
|
use MooseX::Role::Parameterized 1.00; |
|
26
|
|
|
|
|
808
|
|
|
26
|
|
|
|
|
225
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
parameter 'alias_class' => ( |
14
|
|
|
|
|
|
|
is => 'ro', |
15
|
|
|
|
|
|
|
isa => ClassName, |
16
|
|
|
|
|
|
|
required => 1, |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
parameter 'self_param' => ( |
20
|
|
|
|
|
|
|
is => 'ro', |
21
|
|
|
|
|
|
|
isa => Str, |
22
|
|
|
|
|
|
|
required => 1, |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
parameter 'name_param' => ( |
26
|
|
|
|
|
|
|
is => 'ro', |
27
|
|
|
|
|
|
|
isa => Str, |
28
|
|
|
|
|
|
|
default => 'alias_name', |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
role { |
32
|
|
|
|
|
|
|
my $p = shift; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $alias_class = $p->alias_class(); |
35
|
|
|
|
|
|
|
my $self_param = $p->self_param(); |
36
|
|
|
|
|
|
|
my $name_param = $p->name_param(); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
method 'alias' => sub { |
39
|
28
|
|
|
28
|
|
713
|
my $self = shift; |
|
|
|
|
28
|
|
|
|
40
|
28
|
100
|
|
|
|
139
|
my %p = @_ == 1 ? ( $name_param => $_[0] ) : @_; |
41
|
|
|
|
|
|
|
|
42
|
28
|
|
|
|
|
931
|
return $alias_class->new( $self_param => $self, %p ); |
43
|
|
|
|
|
|
|
}; |
44
|
|
|
|
|
|
|
}; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# ABSTRACT: A role for objects with separate alias objects |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=pod |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 NAME |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Fey::Role::MakesAliasObjects - A role for objects with separate alias objects |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 VERSION |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
version 0.43 |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 SYNOPSIS |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
package My::Thing; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
use Moose 2.1200; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
with 'Fey::Role::MakesAliasObjects' |
69
|
|
|
|
|
|
|
=> { alias_class => 'My::Alias', |
70
|
|
|
|
|
|
|
self_param => 'thing', |
71
|
|
|
|
|
|
|
name_param => 'alias_name', |
72
|
|
|
|
|
|
|
}; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 DESCRIPTION |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
This role adds a "make an alias object" method to a class. This is for |
77
|
|
|
|
|
|
|
things like tables and columns, which can have aliases. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 PARAMETERS |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 alias_class |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
The name of the class whose C<new()> is called by the C<alias()> |
84
|
|
|
|
|
|
|
method (see below). Required. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 self_param |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
The name of the parameter to pass C<$self> to the C<alias_class>' |
89
|
|
|
|
|
|
|
C<new()> method as. Required. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 name_param |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
The name of the parameter to C<alias()> that passing a single string |
94
|
|
|
|
|
|
|
is assumed to be. Defaults to C<alias_name>. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 METHODS |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 $obj->alias() |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
my $alias = $obj->alias(alias_name => 'an_alias', %other_params); |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
my $alias = $obj->alias('an_alias'); |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Create a new alias for this object. If a single parameter is |
105
|
|
|
|
|
|
|
provided, it is assumed to be whatever the C<name_param> parameter |
106
|
|
|
|
|
|
|
specifies (see above). |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 BUGS |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
See L<Fey> for details on how to report bugs. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 AUTHOR |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
This software is Copyright (c) 2011 - 2015 by Dave Rolsky. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
This is free software, licensed under: |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=cut |