forked from lix-project/hydra
Get rid of old ToJSON code path
Signed-off-by: Shea Levy <shea@shealevy.com>
This commit is contained in:
parent
a89096ec5e
commit
8e82ba0093
|
@ -9,7 +9,6 @@ use base 'DBIx::Class';
|
||||||
sub TO_JSON {
|
sub TO_JSON {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
if ($self->can("json_hint")) {
|
|
||||||
my $hint = $self->json_hint;
|
my $hint = $self->json_hint;
|
||||||
|
|
||||||
my %json = ();
|
my %json = ();
|
||||||
|
@ -29,38 +28,6 @@ sub TO_JSON {
|
||||||
}
|
}
|
||||||
|
|
||||||
return \%json;
|
return \%json;
|
||||||
} else {
|
|
||||||
my $json = { $self->get_columns };
|
|
||||||
my $rs = $self->result_source;
|
|
||||||
my @relnames = $rs->relationships;
|
|
||||||
RELLOOP: foreach my $relname (@relnames) {
|
|
||||||
my $relinfo = $rs->relationship_info($relname);
|
|
||||||
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;
|
|
||||||
} else {
|
|
||||||
unless (defined $self->{related_resultsets}{$relname}) {
|
|
||||||
my $cond = $relinfo->{cond};
|
|
||||||
if (ref $cond eq 'HASH') {
|
|
||||||
foreach my $k (keys %{$cond}) {
|
|
||||||
my $v = $cond->{$k};
|
|
||||||
$v =~ s/^self\.//;
|
|
||||||
next RELLOOP unless $self->has_column_loaded($v);
|
|
||||||
}
|
|
||||||
} #!!! TODO: Handle ARRAY conditions
|
|
||||||
}
|
|
||||||
if (defined $self->related_resultset($relname)->get_cache) {
|
|
||||||
if ($accessor eq "multi") {
|
|
||||||
$json->{$relname} = [ $self->$relname ];
|
|
||||||
} else {
|
|
||||||
$json->{$relname} = $self->$relname;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $json;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
Loading…
Reference in a new issue