Browse Source
This patch adds a way to tell to_api an attribute needs to be calculated as the count on an existing method/relationship result. For example, if we wanted to include the holds_count attribute for a Koha::Patron object, we would call it: $ patron_json = $patron->to_api({ embed => { holds_count => { is_count => 1 } } }); This way to_api will internally call $json->{holds_count} = $self->holds->count; To test: 1. Apply the tests patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/Object.t => FAIL: Tests fail! 3. Apply this patch 4. Repeat (2) => SUCCESS: Tests pass! 5. Sign off :-D Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>20.05.x
1 changed files with 20 additions and 12 deletions
Loading…
Reference in new issue