|
Lines 356-361
sub _numeric_column_type {
Link Here
|
| 356 |
return ( grep { $column_type eq $_ } @numeric_types) ? 1 : 0; |
356 |
return ( grep { $column_type eq $_ } @numeric_types) ? 1 : 0; |
| 357 |
} |
357 |
} |
| 358 |
|
358 |
|
|
|
359 |
=head3 to_api |
| 360 |
|
| 361 |
my $object_for_api = $object->to_api; |
| 362 |
|
| 363 |
Returns a representation of the object, suitable for API output. |
| 364 |
|
| 365 |
=cut |
| 366 |
|
| 367 |
sub to_api { |
| 368 |
my ( $self ) = @_; |
| 369 |
my $json_object = $self->TO_JSON; |
| 370 |
|
| 371 |
# Rename attributes if there's a mapping |
| 372 |
if ( $self->can('to_api_mapping') ) { |
| 373 |
foreach my $column ( keys %{$self->to_api_mapping} ) { |
| 374 |
my $mapped_column = $self->to_api_mapping->{$column}; |
| 375 |
if ( exists $json_object->{$column} |
| 376 |
&& defined $mapped_column ) |
| 377 |
{ |
| 378 |
# key != undef |
| 379 |
$json_object->{$mapped_column} = delete $json_object->{$column}; |
| 380 |
} |
| 381 |
elsif ( exists $json_object->{$column} |
| 382 |
&& !defined $mapped_column ) |
| 383 |
{ |
| 384 |
# key == undef |
| 385 |
delete $json_object->{$column}; |
| 386 |
} |
| 387 |
} |
| 388 |
} |
| 389 |
|
| 390 |
return $json_object; |
| 391 |
} |
| 392 |
|
| 359 |
=head3 $object->unblessed_all_relateds |
393 |
=head3 $object->unblessed_all_relateds |
| 360 |
|
394 |
|
| 361 |
my $everything_into_one_hashref = $object->unblessed_all_relateds |
395 |
my $everything_into_one_hashref = $object->unblessed_all_relateds |