<commit_before>/*****************************************************************************/
/* Imports */
/*****************************************************************************/
var Controller = Iron.Controller;
var Url = Iron.Url;
var MiddlewareStack = Iron.MiddlewareStack;
var assert = Iron.utils.assert;

/*****************************************************************************/
/* RouteController */
/*****************************************************************************/
RouteController = Controller.extend({
  constructor: function (options) {
    RouteController.__super__.constructor.apply(this, arguments);
    options = options || {};
    this.options = options;
    this._onStopCallbacks = [];
    this.route = options.route;
    this.params = [];

    // Sometimes the data property can be defined on route options,
    // or even on the global router config. And people will expect the
    // data function to be available on the controller instance if it
    // is defined anywhere in the chain. This ensure that if we have
    // a data function somewhere in the chain, you can call this.data().
    this.data = this.lookupOption('data');

    if (typeof this.data === 'function')
      this.data = _.bind(this.data, this);

    this.init(options);
  }
});

/**
 * Returns an option value following an "options chain" which is this path:
 *
 *   this.options
 *   this (which includes the proto chain)
 *   this.route.options
 *   dynamic variable
 *   this.router.options
 */<commit_msg>if controller data is defined make sure its a function<commit_after>/*****************************************************************************/
/* Imports */
/*****************************************************************************/
var Controller = Iron.Controller;
var Url = Iron.Url;
var MiddlewareStack = Iron.MiddlewareStack;
var assert = Iron.utils.assert;

/*****************************************************************************/
/* RouteController */
/*****************************************************************************/
RouteController = Controller.extend({
  constructor: function (options) {
    RouteController.__super__.constructor.apply(this, arguments);
    options = options || {};
    this.options = options;
    this._onStopCallbacks = [];
    this.route = options.route;
    this.params = [];

    // Sometimes the data property can be defined on route options,
    // or even on the global router config. And people will expect the
    // data function to be available on the controller instance if it
    // is defined anywhere in the chain. This ensure that if we have
    // a data function somewhere in the chain, you can call this.data().
    var data = this.lookupOption('data');

    if (typeof data === 'function')
      this.data = _.bind(data, this);
    else if (typeof data !== 'undefined')
      this.data = function () { return data; };

    this.init(options);
  }
});

/**
 * Returns an option value following an "options chain" which is this path:
 *
 *   this.options
 *   this (which includes the proto chain)
 *   this.route.options
 *   dynamic variable
 *   this.router.options
 */
{'fraction_non_alphanumeric': 0.28697293895531784, 'fraction_numerical': 0.0, 'mean_word_length': 3.990580847723705, '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': '1169388', 'n_tokens_mistral': 743, 'n_tokens_neox': 706, 'n_words': 257}