@@ -46,13 +46,8 @@ def <(other)
46
46
end
47
47
48
48
def alias_method ( newname , oldname )
49
- %x{
50
- self.$$proto['$' + newname] = self.$$proto['$' + oldname];
49
+ `self.$$proto['$' + newname] = self.$$proto['$' + oldname]`
51
50
52
- if (self.$$methods) {
53
- $opal.donate(self, ['$' + newname ])
54
- }
55
- }
56
51
self
57
52
end
58
53
@@ -178,15 +173,18 @@ def const_get(name, inherit = true)
178
173
179
174
%x{
180
175
var scopes = [self.$$scope];
176
+
181
177
if (inherit || self == Opal.Object) {
182
178
var parent = self.$$super;
179
+
183
180
while (parent !== Opal.BasicObject) {
184
181
scopes.push(parent.$$scope);
182
+
185
183
parent = parent.$$super;
186
184
}
187
185
}
188
186
189
- for (var i = 0, len = scopes.length; i < len ; i++) {
187
+ for (var i = 0, length = scopes.length; i < length ; i++) {
190
188
if (scopes[i].hasOwnProperty(name)) {
191
189
return scopes[i][name];
192
190
}
@@ -198,11 +196,14 @@ def const_get(name, inherit = true)
198
196
199
197
def const_missing ( const )
200
198
%x{
201
- var autoloader;
199
+ if (self.$$autoload) {
200
+ var file = self.$$autoload[#{ const } ];
201
+
202
+ if (file) {
203
+ self.$require(file);
202
204
203
- if (self.$$autoload && (autoloader = self.$$autoload[#{ const } ])) {
204
- self.$require(autoloader);
205
- return self.$$scope.get(#{ const } );
205
+ return #{ const_get const } ;
206
+ }
206
207
}
207
208
}
208
209
@@ -265,6 +266,10 @@ def include(*mods)
265
266
for (var i = mods.length - 1; i >= 0; i--) {
266
267
var mod = mods[i];
267
268
269
+ if (!mod.$$is_mod) {
270
+ #{ raise TypeError , "wrong argument type #{ `mod` . class . name } (expected Module)" } ;
271
+ }
272
+
268
273
if (mod === self) {
269
274
continue;
270
275
}
@@ -305,15 +310,22 @@ def instance_method(name)
305
310
306
311
def instance_methods ( include_super = false )
307
312
%x{
308
- var methods = [], proto = self.$$proto;
313
+ var methods = [],
314
+ proto = self.$$proto;
309
315
310
- for (var prop in self.$$ proto) {
311
- if (!include_super && !proto.hasOwnProperty( prop) ) {
316
+ for (var prop in proto) {
317
+ if (typeof(proto[ prop]) !== "function" ) {
312
318
continue;
313
319
}
314
320
315
- if (!include_super && proto[prop].$$donated) {
316
- continue;
321
+ if (!self.$$is_mod) {
322
+ if (!include_super && !proto.hasOwnProperty(prop)) {
323
+ continue;
324
+ }
325
+
326
+ if (!include_super && proto[prop].$$donated) {
327
+ continue;
328
+ }
317
329
}
318
330
319
331
if (prop.charAt(0) === '$') {
0 commit comments