If I have a javascript object, I usually interact with the object and its methods as follows:
var obj = someObject.getInstance(); var result = obj.someMethod();
where someMethod is defined as follows:
someObject.prototype.someOtherMethod = function() {
However, I get an error when I want to call someMethod in Ruby via ExecJS:
context = ExecJS.compile(# the javascript file) context.call('someObject.getInstance().someMethod') # Gives a TypeError where Object has no method 'someOtherMethod'
On the other hand, the functions defined in the javascript module work fine:
someFunction = function() {
Can ExecJS handle Javascript objects and their methods, or can I only call functions with it?
As for the specific application, I look at https://github.com/joenoon/libphonenumber-execjs , but the parse function in Libphonenumber does not work for the above reason.
source share