NAME
DBIx::QuickORM::Role::Linked - Role for sources that expose links.
DESCRIPTION
Provides link-resolution for sources that know about DBIx::QuickORM::Link objects. Given a link specification (a name, alias, table, column set, or an existing link object), resolve_link finds the matching link, building and caching a set of lookup indexes the first time it is needed.
SYNOPSIS
package My::Source;
use Role::Tiny::With;
with 'DBIx::QuickORM::Role::Linked';
sub links { ... }
my $link = $source->resolve_link('author');
REQUIRED METHODS
Consumers must provide links, returning the arrayref of DBIx::QuickORM::Link objects this source knows about.
PUBLIC METHODS
- $source->connection
- $source->from
-
Default no-op accessors; consumers override them when they have a connection or can resolve a sub-source by name.
- $link = $source->resolve_link($spec, %params)
- $link = $source->resolve_link(%params)
-
Resolve a link from a specification. Accepts an existing DBIx::QuickORM::Link (returned as-is), a reference (a hashref/arrayref parsed into a link), or a name/alias/table/column lookup. Croaks when the specification cannot be resolved or is ambiguous.
A bare string spec is a fuzzy lookup: it is matched against aliases, then table names, then column keys, and the first hit wins. To force a particular dimension, pass it by keyword instead:
$source->resolve_link(alias => 'author'); # by link alias only $source->resolve_link(table => 'users'); # by destination table only $source->resolve_link(table => 'users', columns => ['user_id']); # by table + columnsaliasandtableresolve standalone;columns(or a precomputedkey) is scoped to a table, so pass it together withtable.
PRIVATE METHODS
- $link = $source->_link_from_name(%params)
-
Look a link up in the cached indexes by table, alias, key, or columns, building the indexes on first use. Returns a single link, an arrayref of candidates, or undef.
SOURCE
The source code repository for DBIx::QuickORM can be found at https://github.com/exodist/DBIx-QuickORM.
MAINTAINERS
AUTHORS
COPYRIGHT
Copyright Chad Granum <exodist7@gmail.com>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.