line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bolts::Locator; |
2
|
|
|
|
|
|
|
$Bolts::Locator::VERSION = '0.143171'; |
3
|
|
|
|
|
|
|
# ABSTRACT: General purpose locator |
4
|
|
|
|
|
|
|
|
5
|
11
|
|
|
11
|
|
43
|
use Moose; |
|
11
|
|
|
|
|
11
|
|
|
11
|
|
|
|
|
59
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has root => ( |
9
|
|
|
|
|
|
|
is => 'ro', |
10
|
|
|
|
|
|
|
isa => 'HashRef|ArrayRef|Object', |
11
|
|
|
|
|
|
|
required => 1, |
12
|
|
|
|
|
|
|
); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
with 'Bolts::Role::RootLocator'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
override BUILDARGS => sub { |
18
|
|
|
|
|
|
|
my $class = shift; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
if (@_ == 1) { |
21
|
|
|
|
|
|
|
return { root => $_[0] }; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
else { |
24
|
|
|
|
|
|
|
return super(); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
}; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
__END__ |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=pod |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=encoding UTF-8 |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 NAME |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Bolts::Locator - General purpose locator |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 VERSION |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
version 0.143171 |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 SYNOPSIS |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my $some_bag = MyApp::SomeBag->new; |
47
|
|
|
|
|
|
|
my $loc = Bolts::Locator->new($some_bag); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# OR better... |
50
|
|
|
|
|
|
|
use Bolts::Util qw( locator_for ); |
51
|
|
|
|
|
|
|
my $loc = locator_for($some_bag); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 DESCRIPTION |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
This can be used to wrap any object, array, or hash reference in a L<Bolts::Role::Locator> interface. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 ROLES |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=over |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=item * |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
L<Bolts::Role::RootLocator> |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=back |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 root |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
This implements L<Bolts::Role::Locator/root> allowing the locator to be applied to any object, array or hash reference. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 METHODS |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 new |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
my $loc = Bolts::Locator->new($bag); |
78
|
|
|
|
|
|
|
my $loc = Bolts::Locator->new( root => $bag ); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
You may call the constructor with only a single argument. In that case, that argument is treated as L</root>. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 AUTHOR |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Andrew Sterling Hanenkamp <hanenkamp@cpan.org> |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This software is copyright (c) 2014 by Qubling Software LLC. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
91
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |