<commit_before>define(['jquery', 'nbd/Controller'], function( $, Controller ) {
  'use strict';

  var constructor = Controller.extend({

    View  : null,
    Model : null,

    init : function( id, data ) {
    
      this.Model = new this.constructor.MODEL_CLASS( id, data );
      this._initView( this.Model );

    }, // init

    // renders this entity
    render : function( $parent, ViewClass ) {

      ViewClass = ViewClass || this.constructor.VIEW_CLASS;

      this.requestView( ViewClass );
      this.View.render( $parent );

    }, // render

    destroy : function() {
      this.View.destroy();
      this.Model = this.View = null;
    }, // destroy

    _initView : function( Model ) {
      this.View = new this.constructor.VIEW_CLASS( Model );
      this.View.Controller = this;
    }, // makeView

    requestView : function( Class ) {

      if ( this.View instanceof Class || !this.Model ) {
        return;
      }

      this.switchView( Class );

    }, // requestView

    switchView : function( Class ) {

      var Existing = this.View;
      this.View = new Class( this.Model );
      this.View.Controller = this;

      if ( Existing && Existing.$view !== null ) {
        this.View.$view = Existing.$view;
        this.View.render();
      }

      Existing.destroy();
    
    } // switchView

  },{
    // Corresponding Entity View class
    VIEW_CLASS : null,

    // Corresponding Entity Model class
    MODEL_CLASS : null
  }); // Entity Controller

  return constructor;

});
<commit_msg>Entity Controller: switchView guard<commit_after>define(['jquery', 'nbd/Controller'], function( $, Controller ) {
  'use strict';

  var constructor = Controller.extend({

    View  : null,
    Model : null,

    init : function( id, data ) {
    
      this.Model = new this.constructor.MODEL_CLASS( id, data );
      this._initView( this.Model );

    }, // init

    // renders this entity
    render : function( $parent, ViewClass ) {

      ViewClass = ViewClass || this.constructor.VIEW_CLASS;

      this.requestView( ViewClass );
      this.View.render( $parent );

    }, // render

    destroy : function() {
      this.View.destroy();
      this.Model = this.View = null;
    }, // destroy

    _initView : function( Model ) {
      this.View = new this.constructor.VIEW_CLASS( Model );
      this.View.Controller = this;
    }, // makeView

    requestView : function( Class ) {

      if ( this.View instanceof Class || !this.Model ) {
        return;
      }

      this.switchView( Class );

    }, // requestView

    switchView : function( Class ) {

      var Existing = this.View;
      this.View = new Class( this.Model );
      this.View.Controller = this;

      if ( Existing && Existing.$view !== null ) {
        this.View.$view = Existing.$view;
        this.View.render();
      }

      return Existing && Existing.destroy();
    
    } // switchView

  },{
    // Corresponding Entity View class
    VIEW_CLASS : null,

    // Corresponding Entity Model class
    MODEL_CLASS : null
  }); // Entity Controller

  return constructor;

});

{'fraction_non_alphanumeric': 0.13288069835111543, 'fraction_numerical': 0.0, 'mean_word_length': 2.160367722165475, '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': '4470498', 'n_tokens_mistral': 930, 'n_tokens_neox': 875, 'n_words': 217}