Skip to content

Commit

Permalink
Classes created with Class.new should have their own scope
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Oct 18, 2013
1 parent e3c2c1e commit 56879e0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion corelib/class.rb
Expand Up @@ -4,9 +4,11 @@ def self.new(sup = Object, &block)
function AnonClass(){};
var klass = Opal.boot(sup, AnonClass)
klass._name = nil;
klass._scope = sup._scope;
klass.__parent = sup;
// inherit scope from parent
$opal.create_scope(sup._scope, klass);
sup.$inherited(klass);
if (block !== nil) {
Expand Down
2 changes: 2 additions & 0 deletions corelib/runtime.js
Expand Up @@ -84,6 +84,8 @@
}
}

Opal.create_scope = create_scope;

/*
* A `class Foo; end` expression in ruby is compiled to call this runtime
* method which either returns an existing class of the given name, or creates
Expand Down

0 comments on commit 56879e0

Please sign in to comment.