1
0
Fork 0
mirror of https://github.com/rubyjs/therubyrhino synced 2023-03-27 23:21:34 -04:00

Merge remote-tracking branch 'alexkwolfe/master'

Conflicts:
	lib/rhino/ruby_object.rb
This commit is contained in:
Charles Lowell 2011-10-06 06:13:09 -05:00
commit 5e677f63f1
3 changed files with 14 additions and 6 deletions

View file

@ -8,7 +8,7 @@ module Rhino
end
def call(cxt, scope, this, args)
To.javascript @callable.call(*args.map {|a| To.ruby(a)})
To.javascript @callable.call(*Array(args).map {|a| To.ruby(a)})
end
end
end

View file

@ -47,8 +47,8 @@ module Rhino
if name == "toString"
return RubyFunction.new(lambda { "[Ruby #{robject.class.name}]"})
end
rb_name = name.gsub(/([a-z])([A-Z])/) {"#{$1}_#{$2.downcase}"}
if (robject.public_methods(false).include?(rb_name))
rb_name = name.gsub(/([a-z])([A-Z])/) {"#{$1}_#{$2.downcase}"}.to_sym
if (robject.public_methods(false).collect(&:to_sym).include?(rb_name))
method = robject.method(rb_name)
if method.arity == 0
To.javascript(method.call)
@ -61,12 +61,11 @@ module Rhino
end
def has(name, start)
rb_name = name.gsub(/([a-z])([A-Z])/) {"#{$1}_#{$2.downcase}"}
To.ruby(start).public_methods(false).respond_to?(rb_name) ? true : super(name,start)
rb_name = name.gsub(/([a-z])([A-Z])/) {"#{$1}_#{$2.downcase}"}.to_sym
To.ruby(start).public_methods(false).collect(&:to_sym).include?(rb_name) ? true : super(name,start)
end
Generic = new
end
end
end

View file

@ -25,6 +25,15 @@ describe Rhino::Context do
end
end
it "allows you to scope the context to an object" do
class MyScope
def foo; proc { 'bar' }; end
end
Context.open(:with => MyScope.new) do |ctx|
ctx.eval("foo()").should == 'bar'
end
end
it "allows you to seal the standard objects so that they cannot be modified" do
Context.open(:sealed => true) do |cxt|
lambda {