'use strict';

var R = require('ramda');
var isEmptyObj = R.pipe(R.keys, R.isEmpty);

function ModelRenderer(model) {
  this.modelName = model.modelName;
  this.attrs = model.attrs;
}

function attrToString(key, value) {
  var output = '- ' + key;
  if (R.has('primaryKey', value)) {
    output += ' (primaryKey)';
  }
  return output;
}

ModelRenderer.prototype.toJSON = function toJSON() {
  return this;
};

ModelRenderer.prototype.toString = function toString() {
    var output = this.modelName;

    if (!isEmptyObj(this.attrs)) {
      output += ':\n';
      output += R.join('\n', R.map(R.apply(attrToString), R.toPairs(this.attrs)));
    }
    return output;
};

module.exports = ModelRenderer;

'use strict';

var R = require('ramda');
var isEmptyObj = R.pipe(R.keys, R.isEmpty);

function ModelRenderer(model) {
  this.modelName = model.modelName;
  this.attrs = model.attrs;
}

function attrToString(key, value) {
  var output = '- ' + key;
  if (R.has('primaryKey', value)) {
    output += ' (primaryKey)';
  }
  return output;
}

ModelRenderer.prototype.toJSON = function toJSON() {
  return R.mapObj(R.identity, this);
};

ModelRenderer.prototype.toString = function toString() {
    var output = this.modelName;

    if (!isEmptyObj(this.attrs)) {
      output += ':\n';
      output += R.join('\n', R.map(R.apply(attrToString), R.toPairs(this.attrs)));
    }
    return output;
};

module.exports = ModelRenderer;

Create plain object in toJSON method
Create plain object in toJSON method

Standard deep equality doesn't seem to fail because it doesn't check for
types (i.e. constructor). However, the deep equality that chai uses
takes that into account and seems like a good idea to remove the
prototype in the object to be used for JSON output.
