ToJSON is automatically called recursively

Signed-off-by: Shea Levy <shea@shealevy.com>
This commit is contained in:
Shea Levy 2013-07-26 13:54:07 -04:00
parent d6b23272e3
commit eab13d8736

View file

@ -16,7 +16,7 @@ sub TO_JSON {
next unless defined $relinfo->{attrs}->{accessor};
my $accessor = $relinfo->{attrs}->{accessor};
if ($accessor eq "single" and exists $self->{_relationship_data}{$relname}) {
$json->{$relname} = $self->$relname->TO_JSON;
$json->{$relname} = $self->$relname;
} else {
unless (defined $self->{related_resultsets}{$relname}) {
my $cond = $relinfo->{cond};
@ -30,9 +30,9 @@ sub TO_JSON {
}
if (defined $self->related_resultset($relname)->get_cache) {
if ($accessor eq "multi") {
$json->{$relname} = [ map { $_->TO_JSON } $self->$relname ];
$json->{$relname} = [ $self->$relname ];
} else {
$json->{$relname} = $self->$relname->TO_JSON;
$json->{$relname} = $self->$relname;
}
}
}