Lines 552-558
Returns a representation of the object, suitable for API output.
Link Here
|
552 |
sub to_api { |
552 |
sub to_api { |
553 |
my ( $self, $params ) = @_; |
553 |
my ( $self, $params ) = @_; |
554 |
|
554 |
|
555 |
return unless $self->accessible; |
555 |
return unless $self->is_accessible_in_context($params); |
556 |
|
556 |
|
557 |
my $json_object = $self->TO_JSON; |
557 |
my $json_object = $self->TO_JSON; |
558 |
|
558 |
|
Lines 938-963
sub _handle_to_api_child {
Link Here
|
938 |
return $res; |
938 |
return $res; |
939 |
} |
939 |
} |
940 |
|
940 |
|
941 |
=head3 accessible |
941 |
=head3 is_accessible_in_context |
942 |
|
942 |
|
943 |
if ( $object->accessible ) { ... } |
943 |
if ( $object->is_accessible_in_context ) { ... } |
944 |
|
944 |
|
945 |
Whether the object should be accessible in the current context (requesting user). |
945 |
Stub method that is expected to be overloaded (if required) by implementing classes. |
946 |
It relies on the plural class properly implementing the I<search_limited> method. |
|
|
947 |
|
946 |
|
948 |
=cut |
947 |
=cut |
949 |
|
948 |
|
950 |
sub accessible { |
949 |
sub is_accessible_in_context { |
951 |
my ($self) = @_; |
950 |
my ($self) = @_; |
952 |
|
951 |
|
953 |
return $self->_get_objects_class->search_limited( |
952 |
return 1; |
954 |
{ |
|
|
955 |
map { $_ => $self->$_ } |
956 |
$self->_result->result_source->primary_columns |
957 |
} |
958 |
)->count > 0 |
959 |
? 1 |
960 |
: 0; |
961 |
} |
953 |
} |
962 |
|
954 |
|
963 |
sub DESTROY { } |
955 |
sub DESTROY { } |