Module: Csso::CallJS
Overview
Utility for calling into the JavaScript runtime.
Instance Method Summary collapse
-
#calljs(err_cls = WrappedError) { ... } ⇒ Object
Wrap JavaScript invocations with uniform error handling.
-
#lock { ... } ⇒ Object
Ensure proper locking before entering the V8 API.
Instance Method Details
#calljs(err_cls = WrappedError) { ... } ⇒ Object
Wrap JavaScript invocations with uniform error handling
9 10 11 12 13 14 15 |
# File 'lib/csso/utils.rb', line 9 def calljs err_cls=WrappedError lock do yield end rescue V8::JSError => e raise err_cls.new(e) end |
#lock { ... } ⇒ Object
Ensure proper locking before entering the V8 API
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/csso/utils.rb', line 21 def lock result, exception = nil, nil V8::C::Locker() do begin result = yield rescue Exception => e exception = e end end if exception raise exception else result end end |