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
11 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
25 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
49 Holds the cached, generated join datastructure.
59 =attribute_public name
61 Sets the key for this level in the generated hash.
71 =method_private _build_joins
73 Finds the top parent in the structure and then recursively iterates the children
74 building out the join datastructure.
82 while ( my $found = $self->parent ) {
83 if ( $found->has_parent ) {
94 map { $foo->{ $_->name } = $builder->($_) } $node->all_children;
98 return $builder->( $parent || $self );
103 JoinBuilder is used to keep track of joins automagically for complex searches.
104 It accomplishes this by building a simple tree of parents and children and then
105 recursively drilling into the tree to produce a useable join attribute for