mirror of
https://github.com/rubyjs/therubyrhino
synced 2023-03-27 23:21:34 -04:00
access ruby properties as javascript properties
This commit is contained in:
parent
bd3acebdc5
commit
3dff206175
1 changed files with 9 additions and 3 deletions
|
@ -21,7 +21,9 @@ module Rhino
|
||||||
end
|
end
|
||||||
|
|
||||||
def getIds()
|
def getIds()
|
||||||
@ruby.public_methods(false).map {|m| m.gsub(/(.)_(.)/) {"#{$1}#{$2.upcase}"}}.to_java
|
puts "getIds()"
|
||||||
|
require 'java'
|
||||||
|
@ruby.public_methods(false).map {|m| m.gsub(/(.)_(.)/) {::JavaLang::String.new("#{$1}#{$2.upcase}")}}.tap {|ids| puts "ids: #{ids.inspect}"}.to_java
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
|
@ -41,7 +43,11 @@ module Rhino
|
||||||
rb_name = name.gsub(/([a-z])([A-Z])/) {"#{$1}_#{$2.downcase}"}
|
rb_name = name.gsub(/([a-z])([A-Z])/) {"#{$1}_#{$2.downcase}"}
|
||||||
if (robject.public_methods(false).include?(rb_name))
|
if (robject.public_methods(false).include?(rb_name))
|
||||||
method = robject.method(rb_name)
|
method = robject.method(rb_name)
|
||||||
RubyFunction.new(method)
|
if method.arity == 0
|
||||||
|
To.javascript(method.call)
|
||||||
|
else
|
||||||
|
RubyFunction.new(method)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
super(name, start)
|
super(name, start)
|
||||||
end
|
end
|
||||||
|
@ -51,7 +57,7 @@ module Rhino
|
||||||
rb_name = name.gsub(/([a-z])([A-Z])/) {"#{$1}_#{$2.downcase}"}
|
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)
|
To.ruby(start).public_methods(false).respond_to?(rb_name) ? true : super(name,start)
|
||||||
end
|
end
|
||||||
|
|
||||||
Generic = new
|
Generic = new
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue