class Rhino::Ruby::AccessBase
Constants
- UNDERSCORES
Public Instance Methods
get(object, name, scope) { || ... }
click to toggle source
# File lib/rhino/ruby/access.rb, line 20 def get(object, name, scope) # try [](name) method : if object.respond_to?(:'[]') && object.method(:'[]').arity == 1 value = begin object[name] rescue LocalJumpError nil end unless internal?(name) return Rhino.to_javascript(value, scope) unless value.nil? end yield end
has(object, name, scope) { || ... }
click to toggle source
# File lib/rhino/ruby/access.rb, line 9 def has(object, name, scope) # try [](name) method : if object.respond_to?(:'[]') && object.method(:'[]').arity == 1 unless internal?(name) value = object.[](name) { return true } return true unless value.nil? end end yield end
put(object, name, value) { || ... }
click to toggle source
# File lib/rhino/ruby/access.rb, line 33 def put(object, name, value) # try []=(name, value) method : if object.respond_to?(:'[]=') && object.method(:'[]=').arity == 2 rb_value = Rhino.to_ruby(value) begin return object[name] = rb_value rescue LocalJumpError end unless internal?(name) end yield end
Private Instance Methods
internal?(name)
click to toggle source
# File lib/rhino/ruby/access.rb, line 49 def internal?(name) # e.g. '__iterator__', '__proto__' name.is_a?(String) && name[0..1] == UNDERSCORES && name[-2..-1] == UNDERSCORES end