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