<commit_before>exports.definition = {
  mixinCallback: function(){
    var self = this
    self.ChainGenerator = null

    this.on('finished', function(){
      var Chain = function(){}
      Chain.prototype = [] // Chain is an array to hold all records

      // Array.find() interference with our own find method - when called via callParent()
      // so, the current solution is to null it!
      Chain.prototype.find = null

      var ChainModelMethods = {
        setInternal: function(name, value){
          this._internal_attributes[name] = value
        },

        getInternal: function(name){
          return this._internal_attributes[name]
        },

        clearInternal: function(name){
          this._internal_attributes[name] = null
        },

        addInternal: function(name, value){
          this._internal_attributes[name] = this._internal_attributes[name] || []
          if(Array.isArray(value)){
            this._internal_attributes[name] = this._internal_attributes[name].concat(value)
          }else{
            this._internal_attributes[name].push(value)
          }
        },

        definition: self,
        model: self.model,
        store: self.store,
        chained: true
      }


      self.store.utils.mixin(Chain.prototype, ChainModelMethods, {enumerable: false})
      self.store.utils.mixin(Chain.prototype, self.model, {enumerable: false})
      self.store.utils.mixin(Chain.prototype, self.store.mixinPaths, {only: 'chain', enumerable: false})


      self.ChainGenerator = function(options){
        var arr = []
        Object.setPrototypeOf(arr, Chain.prototype)
        arr.options = options || {}
        arr._internal_attributes = {}

        self.store.utils.mixinCallbacks(arr)

        return arr
      }
    })
  }
}

/*
 * MODEL
 */
exports.model = {
  /**
   * Returns a Collection, which is in fact a cloned Model - or a chained Model
   * A Collectioin is an Array with all of Models' methods. All `where`, `limit`, `setContext`, ... information will be stored in this chained Model to allow asynchronous usage.
   *
   * @class Model
   * @method chain
   * @param {object} options - The options hash
   * @param {boolean} options.clone - Clone a existing chained object. Default: false
   *
   * @return {Collection}
   */
  chain: function(options){
    options = options || {}
    if(this.chained && options.clone !== true) return this

    var ChainModel = new this.definition.ChainGenerator(options)

    if(this.chained && options.clone === true){     
      ChainModel._internal_attributes = this.definition.store.utils.clone(this._internal_attributes, options.exclude)
    }

    return ChainModel.callDefaultScopes()
  },


  /**
   * Returns a cloned Collection
   *
   * @class Model
   * @method clone
   *<commit_msg>fix clone() in connection with relations #65<commit_after>exports.definition = {
  mixinCallback: function(){
    var self = this
    self.ChainGenerator = null

    this.on('finished', function(){
      var Chain = function(){}
      Chain.prototype = [] // Chain is an array to hold all records

      // Array.find() interference with our own find method - when called via callParent()
      // so, the current solution is to null it!
      Chain.prototype.find = null

      var ChainModelMethods = {
        setInternal: function(name, value){
          this._internal_attributes[name] = value
        },

        getInternal: function(name){
          return this._internal_attributes[name]
        },

        clearInternal: function(name){
          this._internal_attributes[name] = null
        },

        addInternal: function(name, value){
          this._internal_attributes[name] = this._internal_attributes[name] || []
          if(Array.isArray(value)){
            this._internal_attributes[name] = this._internal_attributes[name].concat(value)
          }else{
            this._internal_attributes[name].push(value)
          }
        },

        definition: self,
        model: self.model,
        store: self.store,
        chained: true
      }


      self.store.utils.mixin(Chain.prototype, ChainModelMethods, {enumerable: false})
      self.store.utils.mixin(Chain.prototype, self.model, {enumerable: false})
      self.store.utils.mixin(Chain.prototype, self.store.mixinPaths, {only: 'chain', enumerable: false})


      self.ChainGenerator = function(options){
        var arr = []
        Object.setPrototypeOf(arr, Chain.prototype)
        arr.options = options || {}
        arr._internal_attributes = {}

        self.store.utils.mixinCallbacks(arr)

        return arr
      }
    })
  }
}

/*
 * MODEL
 */
exports.model = {
  /**
   * Returns a Collection, which is in fact a cloned Model - or a chained Model
   * A Collectioin is an Array with all of Models' methods. All `where`, `limit`, `setContext`, ... information will be stored in this chained Model to allow asynchronous usage.
   *
   * @class Model
   * @method chain
   * @param {object} options - The options hash
   * @param {boolean} options.clone - Clone a existing chained object. Default: false
   *
   * @return {Collection}
   */
  chain: function(options){
    options = options || {}
    if(this.chained && options.clone !== true) return this

    var ChainModel = new this.definition.ChainGenerator(options)

    if(this.chained && options.clone === true){     
      ChainModel._internal_attributes = this.definition.store.utils.clone(this._internal_attributes, options.exclude)
      ChainModel.clearInternal('relation_to')
    }

    return ChainModel.callDefaultScopes()
  },


  /**
   * Returns a cloned Collection
   *
   * @class Model
   * @method clone
   *
{'fraction_non_alphanumeric': 0.11414479478597851, 'fraction_numerical': 0.00035229874933943986, 'mean_word_length': 2.5688246385920803, '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': '5152742', 'n_tokens_mistral': 1596, 'n_tokens_neox': 1544, 'n_words': 397}