class Nashorn::Ruby::AccessBase
Constants
- UNDERSCORES
Public Instance Methods
get(object, name) { || ... }
click to toggle source
# File lib/nashorn/ruby/access.rb, line 20 def get(object, name) # try [](name) method : if object.respond_to?(:'[]') && object.method(:'[]').arity == 1 value = begin object[name] rescue LocalJumpError nil end unless internal?(name) return Nashorn.to_js(value) unless value.nil? end yield end
get_slot(object, index, &block)
click to toggle source
# File lib/nashorn/ruby/access.rb, line 49 def get_slot(object, index, &block) get(object, index, &block) end
has(object, name) { || ... }
click to toggle source
# File lib/nashorn/ruby/access.rb, line 9 def has(object, name) # 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
has_slot(object, index, &block)
click to toggle source
# File lib/nashorn/ruby/access.rb, line 45 def has_slot(object, index, &block) has(object, index, &block) end
set(object, name, value) { || ... }
click to toggle source
# File lib/nashorn/ruby/access.rb, line 33 def set(object, name, value) # try []=(name, value) method : if object.respond_to?(:'[]=') && object.method(:'[]=').arity == 2 rb_value = Nashorn.to_rb(value) begin return object[name] = rb_value rescue LocalJumpError end unless internal?(name) end yield end
set_slot(object, index, value, &block)
click to toggle source
# File lib/nashorn/ruby/access.rb, line 53 def set_slot(object, index, value, &block) set(object, index, value, &block) end
Private Instance Methods
internal?(name)
click to toggle source
# File lib/nashorn/ruby/access.rb, line 61 def internal?(name) # e.g. '__iterator__', '__proto__' name.is_a?(String) && name.start_with?(UNDERSCORES) && name.end_with?(UNDERSCORES) end