opal/corelib/runtime.js in opal-1.8.0.beta1 vs opal/corelib/runtime.js in opal-1.8.0
- old
+ new
@@ -938,11 +938,11 @@
Opal.is_method = function(prop) {
return (prop[0] === '$' && prop[1] !== '$');
};
Opal.instance_methods = function(mod) {
- var exclude = [], results = [], ancestors = $ancestors(mod);
+ var processed = Object.create(null), results = [], ancestors = $ancestors(mod);
for (var i = 0, l = ancestors.length; i < l; i++) {
var ancestor = ancestors[i],
proto = ancestor.$$prototype;
@@ -953,22 +953,22 @@
var props = Object.getOwnPropertyNames(proto);
for (var j = 0, ll = props.length; j < ll; j++) {
var prop = props[j];
+ if (processed[prop]) {
+ continue;
+ }
if (Opal.is_method(prop)) {
- var method_name = prop.slice(1),
- method = proto[prop];
+ var method = proto[prop];
- if (method.$$stub && exclude.indexOf(method_name) === -1) {
- exclude.push(method_name);
- }
-
- if (!method.$$stub && results.indexOf(method_name) === -1 && exclude.indexOf(method_name) === -1) {
+ if (!method.$$stub) {
+ var method_name = prop.slice(1);
results.push(method_name);
}
}
+ processed[prop] = true;
}
}
return results;
};
@@ -2205,11 +2205,11 @@
// to keep the max depth at 1.
if (body.$$alias_of) body = body.$$alias_of;
// We need a wrapper because otherwise properties
// would be overwritten on the original body.
- alias = Opal.wrapMethodBody(body);
+ alias = Opal.wrap_method_body(body);
// Try to make the browser pick the right name
alias.displayName = name;
alias.$$alias_of = body;
alias.$$alias_name = name;
@@ -2217,10 +2217,10 @@
Opal.defn(obj, id, alias);
return obj;
};
- Opal.wrapMethodBody = function(body) {
+ Opal.wrap_method_body = function(body) {
var wrapped = function() {
var block = wrapped.$$p;
wrapped.$$p = null;