Bolts::Role::RootLocator - Interface for locating artifacts from some root bag
version 0.143171
This is the interface that any locator must implement. A locator's primary job is to provide a way to find artifacts within a bag or selection of bags. This performs the acquisition and resolution process. This actually also implements everything needed for the process except for the "root".
Bolts::Role::Locator
This is the object to use as the bag to start searching. It may be an object, a reference to an array, or a reference to a hash.
Caution: This will be renamed in the future.
my $artifact = $loc->acquire(@path, \%options);
Given a @path of symbol names to traverse, this goes through each artifact in turn, resolves it, if necessary, and then continues to the next path component.
@path
After it finds the artifact, it will resolve the artifact using the "resolve" method, which is passed the (optional) %options.
When complete, the complete, resolved artifact found is returned.
Acquisition in this implementation proceeds according to the following rules:
If the bag is an object:
If the object implements the Bolts::Role::Opaque role, lookup will end in an error.
If the object implements the Bolts::Role::Locator role, control of the lookup for the remaining components in @path will pass over to that object.
If the can method on the object returns false for the next component in @path, lookup will end in an error.
can
Finally, the method named in the next component in @path will be called and the result used as either the value to resolve or the next bag to locate within (repeating this process).
If the bag is a hash, the name of the next component in @path will be used as a key in the hash to find the next value to resolve or the next bag to locate within.
If the bag is an array and the name of the next component in @path is a number, it will be used as the index to fetch from the array to use as the value to resolve or the next bag to locate within.
Anything else will result in lookup ending in an error.
my @artifacts = @{ $loc->acquire_all(\@path) };
This is similar to acquire, but returns the value as a reference to an array of resolved artifacts.
my $resolved_artifact = $loc->resolve($bag, $artifact, \%options);
After the artifact has been found, this method resolves the a partial artifact implementing the Bolts::Role::Artifact and turns it into the complete artifact.
Andrew Sterling Hanenkamp <hanenkamp@cpan.org>
This software is copyright (c) 2014 by Qubling Software LLC.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Bolts, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Bolts
CPAN shell
perl -MCPAN -e shell install Bolts
For more information on module installation, please visit the detailed CPAN module installation guide.