Skip to content

Commit 930f2fa

Browse files
committedSep 16, 2014
Rename .rb_stub to .$$stub
Ref: #583
1 parent 334059a commit 930f2fa

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed
 

‎lib/opal/nodes/defined.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def compile_call
3333
recv = value[1] ? expr(value[1]) : 'self'
3434

3535
with_temp do |tmp|
36-
push "(((#{tmp} = ", recv, "#{mid}) && !#{tmp}.rb_stub) || ", recv
36+
push "(((#{tmp} = ", recv, "#{mid}) && !#{tmp}.$$stub) || ", recv
3737
push "['$respond_to_missing?']('#{value[2].to_s}') ? 'method' : nil)"
3838
end
3939
end

‎lib/opal/nodes/masgn.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def compile
1717
elsif rhs.type == :to_ary
1818
push "#{tmp} = $opal.to_ary(", expr(rhs[1]), ")"
1919
elsif rhs.type == :splat
20-
push "(#{tmp} = ", expr(rhs[1]), ")['$to_a'] && !#{tmp}['$to_a'].rb_stub ? (#{tmp} = #{tmp}['$to_a']())"
20+
push "(#{tmp} = ", expr(rhs[1]), ")['$to_a'] && !#{tmp}['$to_a'].$$stub ? (#{tmp} = #{tmp}['$to_a']())"
2121
push " : (#{tmp}).$$is_array ? #{tmp} : (#{tmp} = [#{tmp}])"
2222
else
2323
raise "unsupported mlhs type"

‎opal/corelib/kernel.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def method(name)
2525
%x{
2626
var meth = self['$' + name];
2727
28-
if (!meth || meth.rb_stub) {
28+
if (!meth || meth.$$stub) {
2929
#{raise NameError, "undefined method `#{name}' for class `#{self.class.name}'"};
3030
}
3131
@@ -44,7 +44,7 @@ def methods(all = true)
4444
continue;
4545
}
4646
}
47-
if (self[key].rb_stub === undefined) {
47+
if (self[key].$$stub === undefined) {
4848
methods.push(key.substr(1));
4949
}
5050
}
@@ -497,7 +497,7 @@ def respond_to?(name, include_all = false)
497497
%x{
498498
var body = self['$' + name];
499499
500-
if (typeof(body) === "function" && !body.rb_stub) {
500+
if (typeof(body) === "function" && !body.$$stub) {
501501
return true;
502502
}
503503
}

‎opal/corelib/module.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def append_features(klass)
110110
var method = methods[i], current;
111111
112112
113-
if (prototype.hasOwnProperty(method) && !(current = prototype[method]).$$donated && !current.rb_stub) {
113+
if (prototype.hasOwnProperty(method) && !(current = prototype[method]).$$donated && !current.$$stub) {
114114
// if the target class already has a method of the same name defined
115115
// and that method was NOT donated, then it must be a method defined
116116
// by the class so we do not want to override it
@@ -345,7 +345,7 @@ def instance_method(name)
345345
%x{
346346
var meth = self.$$proto['$' + name];
347347
348-
if (!meth || meth.rb_stub) {
348+
if (!meth || meth.$$stub) {
349349
#{raise NameError, "undefined method `#{name}' for class `#{self.name}'"};
350350
}
351351
@@ -419,7 +419,7 @@ def module_exec(&block)
419419
def method_defined?(method)
420420
%x{
421421
var body = self.$$proto['$' + method];
422-
return (!!body) && !body.rb_stub;
422+
return (!!body) && !body.$$stub;
423423
}
424424
end
425425

‎opal/corelib/runtime.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@
458458
*
459459
* Opal.add_stubs(["$foo", "$bar", "$baz="]);
460460
*
461-
* All stub functions will have a private `rb_stub` property set to true so
461+
* All stub functions will have a private `$$stub` property set to true so
462462
* that other internal methods can detect if a method is just a stub or not.
463463
* `Kernel#respond_to?` uses this property to detect a methods presence.
464464
*
@@ -528,7 +528,7 @@
528528
return this.$method_missing.apply(this, [method_name.slice(1)].concat($slice.call(arguments)));
529529
};
530530

531-
method_missing_stub.rb_stub = true;
531+
method_missing_stub.$$stub = true;
532532

533533
return method_missing_stub;
534534
}
@@ -702,7 +702,7 @@
702702
if (value.$$is_array) {
703703
return value;
704704
}
705-
else if (value.$to_ary && !value.$to_ary.rb_stub) {
705+
else if (value.$to_ary && !value.$to_ary.$$stub) {
706706
return value.$to_ary();
707707
}
708708

‎spec/opal/core/kernel/respond_to_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ def some_method
3434
@a.respond_to?(:undefed_method).should be_false
3535
end
3636

37-
it "returns false if a method exists, but is marked with a 'rb_stub' property" do
38-
`#{@a}.$some_method.rb_stub = true`
37+
it "returns false if a method exists, but is marked with a '$$stub' property" do
38+
`#{@a}.$some_method.$$stub = true`
3939
@a.respond_to?(:some_method).should be_false
4040
end
4141
end

0 commit comments

Comments
 (0)
Please sign in to comment.