ResourceCodeService
We need a ResourceCodeService
that will generate a new, unique, and child-friendly resource code for a new Resource.
The service should have a public method, new_code_for
, that receives a not-yet-saved resource
as a parameter, and returns a suitable new code value.
The resource
's attributes will dictate what the code should look like:
- presence of an
institution_id
value should result in a code that includes the institution's code - presence of a parent_id should include the parent resource's code
And finally, the generated code must be unique.
Edited by Mike Kanning