Module: Rhino::Ruby::Scriptable

Included in:
Function, Object
Defined in:
lib/rhino/ruby.rb

Overview

shared JS::Scriptable implementation

Constant Summary collapse

@@access =
nil

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.accessObject



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

def self.access
  @@access ||= Ruby::DefaultAccess
end

.access=(access) ⇒ Object



44
45
46
# File 'lib/rhino/ruby.rb', line 44

def self.access=(access)
  @@access = access
end

Instance Method Details

#get(name, start) ⇒ Object

override Object Scriptable#get(String name, Scriptable start); override Object Scriptable#get(int index, Scriptable start);



14
15
16
# File 'lib/rhino/ruby.rb', line 14

def get(name, start)
  access.get(unwrap, name, self) { super }
end

#getIdsObject

override Object[] Scriptable#getIds();



31
32
33
34
35
36
37
38
39
40
# File 'lib/rhino/ruby.rb', line 31

def getIds
  ids = []
  unwrap.public_methods(false).each do |name| 
    name = name[0...-1] if name[-1, 1] == '=' # 'foo=' ... 'foo'
    name = name.to_s.to_java # java.lang.String
    ids << name unless ids.include?(name)
  end
  super.each { |id| ids.unshift(id) }
  ids.to_java
end

#has(name, start) ⇒ Object

override boolean Scriptable#has(String name, Scriptable start); override boolean Scriptable#has(int index, Scriptable start);



20
21
22
# File 'lib/rhino/ruby.rb', line 20

def has(name, start)
  access.has(unwrap, name, self) { super }
end

#put(name, start, value) ⇒ Object

override void Scriptable#put(String name, Scriptable start, Object value); override void Scriptable#put(int index, Scriptable start, Object value);



26
27
28
# File 'lib/rhino/ruby.rb', line 26

def put(name, start, value)
  access.put(unwrap, name, value) { super }
end