Skip to content

Conversation

kateinoigakukun
Copy link
Member

@kateinoigakukun kateinoigakukun commented May 19, 2022

This PR adds Ruby's JS::Object <-> JS's RbValue object interoperability by wrapping them with each other.

Example

// JS -> Ruby object
const hash = vm.eval(`Hash.new`)
hash.call("store", vm.eval(`"key1"`), vm.wrap(new Object()));
# Ruby -> JS object
js_obj = JS.eval(`return {}`)
js_reflect = JS.eval("return Reflect")
js_reflect.call(:set, JS::Object.wrap(Object.new))

When passing a non-interoperated Ruby Object like `Object` to JS method
from Ruby world, the object has to be JS object.
This patch provides a way to wrap a Ruby object by `RbValue`, which is a
Ruby object representation in JS world.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant