Class Method or Factory method in ember data models


#1

Just wondering if there is a convention or specific precedent for the following code pattern.

I want to define a model and declare a “Class method” or rather custom initializer or factory type method to it that changes how I can instantiate new instances of it.

Imagine the following Person model

import DS from 'ember-data';
var attr = DS.attr;
export default DS.Model.extend({
  first: attr('string'),
  last: attr('string'),
  dob: attr(),

 customCreate: function(f, n, d){
  this.createRecord({}); 
  this.set('first', f);
  this.set('last', l);
  this.set('dob', d);
 }
});

And then downstream I can create an instance like so:

p = Person.customCreate('John', "Smith', '1/1/1970');