1 package Catalyst::Controller::DBIC::API::JoinBuilder;
3 #ABSTRACT: Provides a helper class to automatically keep track of joins in complex searches
5 use MooseX::Types::Moose(':all');
6 use Catalyst::Controller::DBIC::API::Types(':all');
7 use namespace::autoclean;
9 =attribute_public parent is: ro, isa: 'Catalyst::Controller::DBIC::API::JoinBuilder'
11 parent stores the direct ascendant in the datastructure that represents the join
18 predicate => 'has_parent',
20 trigger => sub { my ( $self, $new ) = @_; $new->add_child($self); },
23 =attribute_public children is: ro, isa: ArrayRef['Catalyst::Controller::DBIC::API::JoinBuilder'], traits => ['Array']
25 children stores the immediate descendants in the datastructure that represents the join.
27 Handles the following methods:
29 all_children => 'elements'
30 has_children => 'count'
37 isa => ArrayRef [JoinBuilder],
39 default => sub { [] },
41 all_children => 'elements',
42 has_children => 'count',
47 =attribute_public joins is: ro, isa: HashRef, lazy_build: true
49 joins holds the cached generated join datastructure.
59 =attribute_public name is: ro, isa: Str, required: 1
61 Sets the key for this level in the generated hash
71 =method_private _build_joins
73 _build_joins finds the top parent in the structure and then recursively iterates the children building out the join datastructure
81 while ( my $found = $self->parent ) {
82 if ( $found->has_parent ) {
93 map { $foo->{ $_->name } = $builder->($_) } $node->all_children;
97 return $builder->( $parent || $self );
102 JoinBuilder is used to keep track of joins automgically for complex searches. It accomplishes this by building a simple tree of parents and children and then recursively drilling into the tree to produce a useable join attribute for ->search.