OSC / osc-machete

High level interface to submitting and checking the status of batch jobs (currently OSC specific)
MIT License
1 stars 0 forks source link

Move results validation methods from Job model to Simulation model #69

Open ericfranz opened 8 years ago

ericfranz commented 8 years ago

If we have osc-machete-rails with a generic Job model, this could simplify the developer experience.

Technically, ActiveRecord model's primary concern is to handle persistence to a database. So its reasonable to say that the methods used to validate the results of a simulation produced by one or more jobs do not belong in the Job model.

The domain specific knowledge would then be isolated to the Simulation object. A simple way is to try the “parent” object first, and if the hook method is not implemented, then try the Job object itself (that solution would be backwards compatible - let the developer implement the expected method on either model).

The problem, however, is that “Statusable” is a module, i.e. not aware of being “owned” by a parent object via a relation. So this would have to be re-thought.

Another option: instead of calling specific hook methods on Statusable#results_valid? the Job object posts an “event” that the job completed and the results need validated and then any object in the app can subscribe to that event and handle this (including the updating of the Job).