Module: Dommy::Bridge::Methods
- Included in:
- AbortController, AbortSignal, Animation, Attr, Dommy::Blob, Dommy::BroadcastChannel, CSSNamespace, CSSRuleList, CSSStyleSheet, CharacterDataNode, ClassList, Clipboard, CookieStore, Crypto, CustomElementRegistry, DOMImplementation, DOMParser, DataTransfer, Document, DocumentType, Element, Event, EventSource, FileList, FileReader, FormData, Fragment, Geolocation, HTMLCollection, Headers, History, IntersectionObserver, KeyframeEffect, LiveNodeList, Location, LockManager, MediaQueryList, MessagePort, MutationObserver, NamedNodeMap, Navigator, NodeIterator, NodeList, Notification, Performance, PerformanceObserver, PermissionStatus, Permissions, ProcessingInstruction, PromiseValue, Range, ReadableStream, ReadableStreamDefaultController, ReadableStreamDefaultReader, Request, ResizeObserver, Response, Selection, ShadowRoot, StandaloneEventTarget, Storage, StorageManager, StyleDeclaration, SubtleCrypto, TextDecoder, TextEncoder, TouchList, TransformStreamDefaultController, TreeWalker, URL, URLPattern, URLSearchParams, ViewTransition, WakeLock, WakeLockSentinel, WebSocket, Window, Worker, WritableStream, WritableStreamDefaultWriter, XMLHttpRequest, XMLHttpRequestUpload, XMLSerializer
- Defined in:
- lib/dommy/bridge/methods.rb
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 |