Applyy extract method to check input options

This commit is contained in:
Daniel García Aubert 2017-09-15 11:44:20 +02:00
parent 419b29e609
commit d4bb4edd1d

View File

@ -53,6 +53,16 @@ module.exports = class Formula extends BaseDataview {
constructor (query, options = {}, queries = {}) {
super();
this._checkOptions(options);
this.query = query;
this.queries = queries;
this.column = options.column || '1';
this.operation = options.operation;
this._isFloatColumn = null;
}
_checkOptions (options) {
if (typeof options.operation !== 'string') {
throw new Error(`Formula expects 'operation' in dataview options`);
}
@ -64,12 +74,6 @@ module.exports = class Formula extends BaseDataview {
if (options.operation !== 'count' && typeof options.column !== 'string') {
throw new Error(`Formula expects 'column' in dataview options`);
}
this.query = query;
this.queries = queries;
this.column = options.column || '1';
this.operation = options.operation;
this._isFloatColumn = null;
}