Skip to content

Commit

Permalink
WipRdpSequenceModel classes pass class level values in options parame…
Browse files Browse the repository at this point in the history
…ter to WipRdpAbstractSequence
  • Loading branch information
AJamesPhillips committed Jul 29, 2015
1 parent 098f1fe commit e28abd3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
16 changes: 8 additions & 8 deletions public/scripts/library/rdp/wip_rdp_abstract_sequence.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import RdpEdit from './rdp_edit';


class WipRdpAbstractSequence extends Sequence {
constructor(attributes, ...other) {
if(!attributes.Klass) throw new TypeError('Must provide Klass attribute');
if(!attributes.types) throw new TypeError('Must provide types attribute');
var Klass = attributes.Klass;
var types = _.clone(attributes.types);
delete attributes.Klass;
delete attributes.types;
constructor(attributes, options={}) {
if(!options.Klass) throw new TypeError('Must provide Klass attribute');
if(!options.types) throw new TypeError('Must provide types attribute');
var Klass = options.Klass;
var types = _.clone(options.types);
delete options.Klass;
delete options.types;

attributes.readOnly = true;
super(attributes, ...other);
super(attributes, options);
this.Klass = Klass;
this.types = types;

Expand Down
11 changes: 4 additions & 7 deletions public/scripts/library/rdp/wip_rdp_oligo_sequence.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@ var wip_rdp_oligo_sequence = 'wip_rdp_oligo_sequence';


class WipRdpOligoSequence extends WipRdpAbstractSequence {
constructor(attrs, ...args) {
if(attrs._type && attrs._type !== wip_rdp_oligo_sequence) {
throw new TypeError(`WipRdpPcrSequence expected _type of "${wip_rdp_oligo_sequence}" but was "${attrs._type}"`);
}
attrs.Klass = WipRdpOligoSequence;
attrs.types = RdpTypes.oligoTypes;
super(attrs, ...args);
constructor(attrs, options={}) {
options.Klass = WipRdpOligoSequence;
options.types = RdpTypes.oligoTypes;
super(attrs, options);
this.set({_type: wip_rdp_oligo_sequence}, {silent: true});
}

Expand Down
8 changes: 4 additions & 4 deletions public/scripts/plugins/pcr/lib/wip_rdp_pcr_sequence.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ var wip_rdp_pcr_product = 'wip_rdp_pcr_product';


class WipRdpPcrSequence extends WipRdpAbstractSequence {
constructor(attributes, ...other) {
attributes.Klass = WipRdpPcrSequence;
attributes.types = RdpTypes.pcrTypes;
super(attributes, ...other);
constructor(attributes, options={}) {
options.Klass = WipRdpPcrSequence;
options.types = RdpTypes.pcrTypes;
super(attributes, options);
this.set({_type: wip_rdp_pcr_product}, {silent: true});
}

Expand Down

0 comments on commit e28abd3

Please sign in to comment.