Skip to content

Commit

Permalink
I think this is the real deal
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur Axel 'fREW' Schmidt committed Apr 11, 2012
1 parent 86ffbd6 commit a475e94
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lib/DU/Schema/Result/Ingredient.pm
Expand Up @@ -27,4 +27,29 @@ belongs_to kind_of => '::Ingredient', 'kind_of_id', { join_type => 'left' };
has_many inventory_items => '::InventoryItem', 'ingredient_id';
has_many links_to_drink_ingredients => '::Drink_Ingredient', 'ingredient_id';

belongs_to
kind_of => '::Ingredient',
sub {
my $args = shift;

my $path_separator = q(/);
my $rest = "$path_separator%";

return ({
"$args->{self_alias}.materialized_path" => {
-like => {
-concat => [
{ -ident => "$args->{foreign_alias}.materialized_path" },
$rest
]
}
}
},
$args->{self_rowobj} && {
"$args->{foreign_alias}.id" => {
-in => split qr(/), $args->{self_rowobj}->materialized_path
}
});
};

1;

0 comments on commit a475e94

Please sign in to comment.