Module: Dommy::Bridge::Methods

Overview

Declares, in one line, the set of JS-callable method names a bridge class routes through __js_call__ (as opposed to data properties read via __js_get__). The QuickJS host reads __js_method_names__ once per interface to decide which property names to expose as callable functions.

class Blob
include Bridge::Methods
js_methods %w[slice text arrayBuffer]
def __js_call__(method, args) = ...
end

Subclasses compose automatically: a subclass's own js_methods are merged with its ancestors' (ancestors first), so __js_call__ ... else super chains stay in sync with the exposed names without a manual super + own.

The per-class JS_METHOD_NAMES constant holds the class's OWN names; the suite asserts it matches the class's own __js_call__ when arms — see test/test_js_call_dispatch_invariant.rb.

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



24
25
26
# File 'lib/dommy/bridge/methods.rb', line 24

def self.included(base)
  base.extend(ClassMethods)
end