-
Notifications
You must be signed in to change notification settings - Fork 2
object conversion
sergeych edited this page Dec 27, 2014
·
3 revisions
- integers are converted to Fixnum
- other numbers are converted to Float
- Strings are converted to ruby strings
- undefined turns into [H8::Undefined] (http://www.rubydoc.info/gems/h8/H8/UndefinedClass)
- null turns to nil
- functions are converted to H8::Value the which provides
#call
and#to_proc
- Other objects are also converted to H8::Value which provides access to properties, methods or use object as callable.
The H8::Value object that is often passed/returned from javascript could be easily converted to ruby's primitive using its #to_ruby
method.
- integers, strings and floats are converted to javascript primitives
- ruby objects are converted to objects
- properties will try to call ruby's methods with no arguments
- methods will call ruby methods with arguments
- ruby callables are converted to javascript functions
If you pass ruby object to the javascript code and then again to the ruby code, the source ruby object will be unwrapped.
The same source javascript object will be unwrapped if passed through ruby code to javasctipt code again.
This is especially convenient with exceptions.
Are converted between languages properly. Unhandled exceptions will be raised/thrown in the caller's environment.