Lines 554-565
sub to_api {
Link Here
|
554 |
my $json_object = $self->TO_JSON; |
554 |
my $json_object = $self->TO_JSON; |
555 |
|
555 |
|
556 |
# Remove forbidden attributes if required |
556 |
# Remove forbidden attributes if required |
557 |
# FIXME: We should eventually require public_read_list in all objects and drop the conditional here. |
557 |
if ( $params->{public} ) { |
558 |
if ( $params->{public} |
|
|
559 |
and $self->can('public_read_list') ) |
560 |
{ |
561 |
for my $field ( keys %{$json_object} ) { |
558 |
for my $field ( keys %{$json_object} ) { |
562 |
delete $json_object->{$field} unless any { $_ eq $field } @{$self->public_read_list}; |
559 |
delete $json_object->{$field} unless any { $_ eq $field } @{ $self->public_read_list }; |
563 |
} |
560 |
} |
564 |
} |
561 |
} |
565 |
|
562 |
|
Lines 649-654
sub to_api_mapping {
Link Here
|
649 |
return {}; |
646 |
return {}; |
650 |
} |
647 |
} |
651 |
|
648 |
|
|
|
649 |
=head3 public_read_list |
650 |
|
651 |
|
652 |
my @public_read_list = @{$object->public_read_list}; |
653 |
|
654 |
Generic method that returns the list of database columns that are allowed to |
655 |
be passed to render objects on the public API. |
656 |
|
657 |
Note: this only returns an empty I<arrayref>. Each class should have its |
658 |
own implementation. |
659 |
|
660 |
=cut |
661 |
|
662 |
sub public_read_list |
663 |
{ |
664 |
return []; |
665 |
} |
666 |
|
652 |
=head3 from_api_mapping |
667 |
=head3 from_api_mapping |
653 |
|
668 |
|
654 |
my $mapping = $object->from_api_mapping; |
669 |
my $mapping = $object->from_api_mapping; |
655 |
- |
|
|