Closed syphax-bouazzouni closed 1 year ago
This PR adds the possibility to add an onUpdate callback to a model attribute
For example
attribute :name, enforce: [:string, :existence] attribute :first_name, onUpdate: :update_name attribute :last_name, onUpdate: :update_name def update_name(inst, attr) self.name = self.first_name + self.last_name end
Will ensure that each time we update firt_name or last_name we call the method update_name and make that name will always be firt_name + last_name
update_name
add onUpdate callback tests (https://github.com/ontoportal-lirmm/goo/pull/31/commits/c83687e9a65c25313df6d74be96e83ace9d939c7)
implement enforce_callback to run an attribute callback (https://github.com/ontoportal-lirmm/goo/pull/31/commits/e4979ffbb8e1d203d0db9368be1871ba172a5b69)
move the attribute default callback to the save method (https://github.com/ontoportal-lirmm/goo/pull/31/commits/c7f7092a228b563d4637533131446015d0f36957)
implement onUpdate DSL in the ressource settings (https://github.com/ontoportal-lirmm/goo/pull/31/commits/f81b15fd04c10e563d40bf0ab724fa9d810a18ce)
call to the attributes onUpdate callback in the save method (https://github.com/ontoportal-lirmm/goo/pull/31/commits/714f085983a2695f4ea8caf7dea00b8883139cb3)
Requirement
This PR adds the possibility to add an onUpdate callback to a model attribute
For example
Will ensure that each time we update firt_name or last_name we call the method
update_name
and make that name will always be firt_name + last_nameChanges
add onUpdate callback tests (https://github.com/ontoportal-lirmm/goo/pull/31/commits/c83687e9a65c25313df6d74be96e83ace9d939c7)
implement enforce_callback to run an attribute callback (https://github.com/ontoportal-lirmm/goo/pull/31/commits/e4979ffbb8e1d203d0db9368be1871ba172a5b69)
move the attribute default callback to the save method (https://github.com/ontoportal-lirmm/goo/pull/31/commits/c7f7092a228b563d4637533131446015d0f36957)
implement onUpdate DSL in the ressource settings (https://github.com/ontoportal-lirmm/goo/pull/31/commits/f81b15fd04c10e563d40bf0ab724fa9d810a18ce)
call to the attributes onUpdate callback in the save method (https://github.com/ontoportal-lirmm/goo/pull/31/commits/714f085983a2695f4ea8caf7dea00b8883139cb3)