Class: Dommy::Bridge::JSValue

Inherits:
Object
  • Object
show all
Defined in:
lib/dommy/bridge.rb

Overview

An opaque handle to a JS-side value that Ruby only stores and hands back (an AbortSignal’s reason, a CustomEvent’s detail). A non-plain JS object (Error, class instance, …) crosses as one of these instead of being flattened to a Hash, so it round-trips with IDENTITY preserved. ‘to_s` exposes the captured JS string form for the rare Ruby consumer that needs text (e.g. building a message).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ref, label = nil) ⇒ JSValue

Returns a new instance of JSValue.



49
50
51
52
# File 'lib/dommy/bridge.rb', line 49

def initialize(ref, label = nil)
  @ref = ref
  @label = label
end

Instance Attribute Details

#refObject (readonly)

Returns the value of attribute ref.



47
48
49
# File 'lib/dommy/bridge.rb', line 47

def ref
  @ref
end

Instance Method Details

#inspectObject



55
# File 'lib/dommy/bridge.rb', line 55

def inspect = "#<Dommy::Bridge::JSValue #{to_s}>"

#to_sObject



54
# File 'lib/dommy/bridge.rb', line 54

def to_s = (@label || "[object]").to_s