Module: Dommy::Bridge::Methods
- Included in:
- AbortController, AbortSignal, Animation, Attr, Dommy::Blob, Dommy::BroadcastChannel, CSSNamespace, CSSRuleList, CSSStyleSheet, CanvasGradient, CanvasRenderingContext2D, CharacterDataNode, ClassList, Clipboard, CookieStore, Crypto, CustomElementRegistry, DOMImplementation, DOMParser, DataTransfer, Document, DocumentType, Element, Event, EventSource, FileList, FileReader, FormData, Fragment, Geolocation, HTMLCanvasElement, HTMLCollection, Headers, History, Internal::CSS::ComputedStyleDeclaration, IntersectionObserver, KeyframeEffect, LiveNodeList, Location, LockManager, MediaList, MediaQueryList, MessagePort, MutationObserver, NamedNodeMap, Navigator, NodeIterator, NodeList, Notification, Performance, PerformanceObserver, PermissionStatus, Permissions, PromiseValue, Range, ReadableStream, ReadableStreamDefaultController, ReadableStreamDefaultReader, Request, ResizeObserver, Response, RuleStyleDeclaration, Screen, ScreenOrientation, 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 |