Module: Nashorn::Ruby::Scriptable

Includes:
JS::JSObject
Included in:
Function, Object
Defined in:
lib/nashorn/ruby.rb

Overview

Shared “JSObject” implementation.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#unwrapObject (readonly)

Returns the value of attribute unwrap.



33
34
35
# File 'lib/nashorn/ruby.rb', line 33

def unwrap
  @unwrap
end

Instance Method Details

#getMember(name) ⇒ Object



36
37
38
39
# File 'lib/nashorn/ruby.rb', line 36

def getMember(name)
  return nil if exclude?(name)
  Ruby.access.get(unwrap, name) { super }
end

#getSlot(name) ⇒ Object



54
55
56
57
# File 'lib/nashorn/ruby.rb', line 54

def getSlot(name)
  return nil if exclude?(name)
  Ruby.access.get_slot(unwrap, name) { super }
end

#hasMember(name) ⇒ Object



42
43
44
45
# File 'lib/nashorn/ruby.rb', line 42

def hasMember(name)
  return nil if exclude?(name)
  Ruby.access.has(unwrap, name) { super }
end

#hasSlot(name) ⇒ Object



60
61
62
63
# File 'lib/nashorn/ruby.rb', line 60

def hasSlot(name)
  return nil if exclude?(name)
  Ruby.access.has_slot(unwrap, name) { super }
end

#keySetObject



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/nashorn/ruby.rb', line 77

def keySet
  ids = java.util.HashSet.new
  super_set = super
  unwrap.public_methods(false).each do |name|
    next unless name = convert(name.to_s)
    unless super_set.include?(name)
      ids.add name.to_java # java.lang.String
    end
  end
  ids
end

#removeMember(name) ⇒ Object



72
73
74
# File 'lib/nashorn/ruby.rb', line 72

def removeMember(name)
  setMember(name, nil) # TODO remove_method?
end

#setMember(name, value) ⇒ Object



48
49
50
51
# File 'lib/nashorn/ruby.rb', line 48

def setMember(name, value)
  return nil if exclude?(name)
  Ruby.access.set(unwrap, name, value) { super }
end

#setSlot(name, value) ⇒ Object



66
67
68
69
# File 'lib/nashorn/ruby.rb', line 66

def setSlot(name, value)
  return nil if exclude?(name)
  Ruby.access.set_slot(unwrap, name, value) { super }
end