Thatcher,
Oops, I almost missed your email because I was on vacation. I'm so
sorry for the late response! What you want to do is override the
default access strategy.
Each context lets you tell it how you want your ruby objects to
appear. The "safe" way is just the default.
the access object needs to define 8 methods (4 really, but you need
one each for named property access and indexed property access). Each
method is passed a block. yielding to this block
tells the ruby racer "I don't know anything about this method" This is
how, for example you make a ruby property undefined as opposed to
null.
get(obj, name, &dontintercept)
iget(obj, index, &dontintercept)
set(obj, name, value, &dontintercept)
iset(obj, index, value, &dontintercept)
# this is for metadata about the property... things like
# DONTENUM and DONTDELETE, etc...
# you probably won't need it
query(obj, name, attributes)
iquery(obj, index, attributes)
#returns all enumerable property names
names(obj)
#returns all enumerable property indicies
indices(obj)
This is the default "safe" implementation:
https://github.com/cowboyd/therubyracer/blob/master/lib/v8/access.rb
I'd start by subclassing that.
hope that helps! And sorry I missed your original message.
cheers,
Charles
On Dec 30 2010, 12:37 pm, Thatcher <
thatcher.christop...@gmail.com>
wrote:
> The wiki mentions that therubyracer is safe by default in terms of
> object access but I'd like to allow it to be unsafe. I don't see an
> example illustrating how to achieve this. Is this possible?
>
> From the wiki page (
https://github.com/cowboyd/therubyracer/wiki/Accessing-Ruby-Objects-F...