<commit_before>var _ = require('lodash');

Krypton.Relation = Class(Krypton, 'Relation')({
  prototype : {
    name : null,
    ownerModel : null,
    relatedModel : null,
    ownerCol : null,
    relatedCol : null,
    scope : null,
    /*
    through : {
      tableName : null,
      ownerCol : null,
      relatedCol : null,
      scope : null
    } */
    through : null,

    init : function(config) {
      if (!config.ownerModel) {
        throw new Error('Must provide an ownerModel');
      }

      if (!config.ownerModel.superClass.constructor instanceof Krypton.Model) {
        throw new Error('ownerModel is not a subclass of Krypton.Model');
      }

      if (!config.relatedModel) {
        throw new Error('Must provide a relatedModel');
      }

      if (!config.relatedModel.superClass.constructor instanceof Krypton.Model) {
        throw new Error('relatedModel is not a subclass of Krypton.Model');
      }

      if (!config.ownerCol || !_.isString(config.ownerCol)) {
        throw new Error('Invalid or missing ownerCol');
      }

      if (!config.relatedCol || !_.isString(config.relatedCol)) {
        throw new Error('Invalid or missing relatedCol');
      }

      if (config.through) {
        if (!_.isObject(config.through)) {
          throw new Error('Invalid through declaration');
        }

        if (!_.isString(config.through.tableName) || !_.isString(config.through.ownerCol) || !_.isString(config.through.relatedCol)) {
          throw new Error('Invalid through declaration');
        }
      }

      Object.keys(config || {}).forEach(function (propertyName) {
        this[propertyName] = config[propertyName];
      }, this);

      return this;
    },

    fetch : function() {
      throw Error('Not implemented');
    }
  }
});

module.exports = Krypton.Relation;
<commit_msg>Fix to check if ownerModel and relatedModel are subclasses of Krypton.Model<commit_after>var _ = require('lodash');

Krypton.Relation = Class(Krypton, 'Relation')({
  prototype : {
    name : null,
    ownerModel : null,
    relatedModel : null,
    ownerCol : null,
    relatedCol : null,
    scope : null,
    /*
    through : {
      tableName : null,
      ownerCol : null,
      relatedCol : null,
      scope : null
    } */
    through : null,

    init : function(config) {
      if (!config.ownerModel) {
        throw new Error('Must provide an ownerModel');
      }

      if (config.ownerModel.superClass !== Krypton.Model) {
        throw new Error('ownerModel is not a subclass of Krypton.Model');
      }

      if (!config.relatedModel) {
        throw new Error('Must provide a relatedModel');
      }

      if (config.relatedModel.superClass !== Krypton.Model) {
        throw new Error('relatedModel is not a subclass of Krypton.Model');
      }

      if (!config.ownerCol || !_.isString(config.ownerCol)) {
        throw new Error('Invalid or missing ownerCol');
      }

      if (!config.relatedCol || !_.isString(config.relatedCol)) {
        throw new Error('Invalid or missing relatedCol');
      }

      if (config.through) {
        if (!_.isObject(config.through)) {
          throw new Error('Invalid through declaration');
        }

        if (!_.isString(config.through.tableName) || !_.isString(config.through.ownerCol) || !_.isString(config.through.relatedCol)) {
          throw new Error('Invalid through declaration');
        }
      }

      Object.keys(config || {}).forEach(function (propertyName) {
        this[propertyName] = config[propertyName];
      }, this);

      return this;
    },

    fetch : function() {
      throw Error('Not implemented');
    }
  }
});

module.exports = Krypton.Relation;

{'fraction_non_alphanumeric': 0.1273072747014115, 'fraction_numerical': 0.0, 'mean_word_length': 2.44392523364486, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2442071', 'n_tokens_mistral': 1070, 'n_tokens_neox': 1043, 'n_words': 256}