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.



60
61
62
63
# File 'lib/dommy/bridge.rb', line 60

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

Instance Attribute Details

#refObject (readonly)

Returns the value of attribute ref.



58
59
60
# File 'lib/dommy/bridge.rb', line 58

def ref
  @ref
end

Instance Method Details

#inspectObject



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

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

#to_sObject



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

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