module Rhino::Ruby::Scriptable
shared JS::Scriptable implementation
Constants
- FETCH
- STORE
Public Class Methods
access()
click to toggle source
# File lib/rhino/ruby.rb, line 29 def self.access @@access ||= Ruby::DefaultAccess.new end
access=(access)
click to toggle source
# File lib/rhino/ruby.rb, line 9 def self.access=(access) @@access = ( access.respond_to?(:get) && access.respond_to?(:put) ) ? access : begin access = if access && ! access.is_a?(Class) # Scriptable.access = :attribute name = access.to_s.chomp('_access') name = name[0, 1].capitalize << name[1..-1] name = :"#{name}Access" if Ruby.const_defined?(name) Ruby.const_get(name) # e.g. Rhino::Ruby::AttributeAccess else const_get(name) # e.g. Rhino::Ruby::Scriptable::FooAccess end else # nil, false, Class access end access.is_a?(Class) ? access.new : access end end
Public Instance Methods
get(name, start)
click to toggle source
override Object
Scriptable#get
(String name, Scriptable
start); override Object
Scriptable#get
(int index, Scriptable
start);
Calls superclass method
# File lib/rhino/ruby.rb, line 35 def get(name, start) return nil if exclude?(name) access.get(unwrap, name, self) { super } end
getIds()
click to toggle source
override Object[] Scriptable#getIds()
;
Calls superclass method
# File lib/rhino/ruby.rb, line 55 def getIds ids = [] unwrap.public_methods(false).each do |name| next unless name = convert(name) 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)
click to toggle source
override boolean Scriptable#has
(String name, Scriptable
start); override boolean Scriptable#has
(int index, Scriptable
start);
Calls superclass method
# File lib/rhino/ruby.rb, line 42 def has(name, start) return nil if exclude?(name) access.has(unwrap, name, self) { super } end
put(name, start, value)
click to toggle source
override void Scriptable#put
(String name, Scriptable
start, Object
value); override void Scriptable#put
(int index, Scriptable
start, Object
value);
Calls superclass method
# File lib/rhino/ruby.rb, line 49 def put(name, start, value) return nil if exclude?(name) access.put(unwrap, name, value) { super } end
Private Instance Methods
access()
click to toggle source
# File lib/rhino/ruby.rb, line 85 def access Scriptable.access end
convert(name)
click to toggle source
# File lib/rhino/ruby.rb, line 68 def convert(name) if exclude?(name) nil elsif name[-1, 1] == '=' name[0...-1] else name end end
exclude?(name)
click to toggle source
# File lib/rhino/ruby.rb, line 81 def exclude?(name) name == FETCH || name == STORE end