ncbo / goo

Graph Oriented Objects (GOO) for Ruby. A RDF/SPARQL based ORM.
http://ncbo.github.io/goo/
Other
15 stars 6 forks source link

Feature: add models on update callbacks #144

Closed syphax-bouazzouni closed 5 months ago

syphax-bouazzouni commented 1 year ago

Requirement

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

Changes

syphax-bouazzouni commented 5 months ago

replaced by https://github.com/ncbo/goo/pull/151