Skip to content

Commit 1da9826

Browse files
committedNov 9, 2013
Fix Module#module_exec to pass arguments to block
1 parent 5f5db44 commit 1da9826

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed
 

‎opal/core/module.rb

+18-2
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,24 @@ def module_eval(&block)
366366
end
367367

368368
alias class_eval module_eval
369-
alias class_exec module_eval
370-
alias module_exec module_eval
369+
370+
def module_exec(&block)
371+
%x{
372+
if (block === nil) {
373+
throw new Error("no block given");
374+
}
375+
376+
var block_self = block._s, result;
377+
378+
block._s = null;
379+
result = block.apply(self, $slice.call(arguments));
380+
block._s = block_self;
381+
382+
return result;
383+
}
384+
end
385+
386+
alias class_exec module_exec
371387

372388
def method_defined?(method)
373389
%x{

0 commit comments

Comments
 (0)
Please sign in to comment.