Skip to content

Commit

Permalink
Name anonymous classes when assigning to a constant
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Oct 14, 2013
1 parent 34f06e3 commit 5cc56f3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 2 additions & 6 deletions corelib/module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,9 @@ def const_set(name, value)
rescue
raise TypeError, 'conversion with #to_str failed'
end
%x{
#{self}._scope[name] = #{value};
if (value._isClass && value._name === nil) {
value._name = #{self.name} + '::' + name;
}

%x{
$opal.casgn(self, name, value);
return #{value}
}
end
Expand Down
4 changes: 4 additions & 0 deletions corelib/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,10 @@
Opal.casgn = function(base_module, name, value) {
var scope = base_module._scope;

if (value._isClass && value._name === nil) {
value._name = base_module._name + '::' + name;
}

scope.constants.push(name);
return scope[name] = value;
};
Expand Down

0 comments on commit 5cc56f3

Please sign in to comment.