Permalink
Browse files

Module#include now uses the including object specified in the options…

… hash for all internel include() calls, which means that overriding include() on a class will have the desired effect.
  • Loading branch information...
jcoglan committed Aug 29, 2008
1 parent 21402d0 commit bdec1b7f0f968d58760aacd95c174d67208b0cb4
Showing with 9 additions and 7 deletions.
  1. +9 −7 source/class.js
View
@@ -128,33 +128,35 @@ JS.extend(JS.Module.prototype, {
include: function(module, options, resolve) {
if (!module) return resolve && this.resolve();
options = options || {};
- var inc = module.include, ext = module.extend, modules, i, n, method;
+ var inc = module.include, ext = module.extend, modules, i, n, method,
+ includer = options.included || this;
+
if (module.__inc__ && module.__fns__) {
this.__inc__.push(module);
module.__dep__.push(this);
if (options.extended) module.extended && module.extended(options.extended);
- else module.included && module.included(options.included || this);
+ else module.included && module.included(includer);
}
else {
if (options.recall) {
for (method in module) {
if (JS.ignore(method, module[method])) continue;
- this.define(method, module[method], {notify: options.included || options.extended || this});
+ this.define(method, module[method], {notify: includer || options.extended || this});
}
} else {
if (typeof inc === 'object') {
modules = [].concat(inc);
for (i = 0, n = modules.length; i < n; i++)
- this.include(modules[i], options);
+ includer.include(modules[i], options);
}
if (typeof ext === 'object') {
modules = [].concat(ext);
for (i = 0, n = modules.length; i < n; i++)
- (options.included || this).extend(modules[i], false);
- (options.included || this).extend();
+ includer.extend(modules[i], false);
+ includer.extend();
}
options.recall = true;
- return this.include(module, options, resolve);
+ return includer.include(module, options, resolve);
}
}
resolve && this.resolve();

0 comments on commit bdec1b7

Please sign in to comment.