Class: Dommy::Bridge::ConstructorRegistry

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

Overview

Maps JS global constructor names (e.g. “Event”, “URL”, “XMLHttpRequest”) to their ‘Bridge::Constructor` instances. Window builds one and routes `js_get` name lookups through it, instead of carrying one ivar plus one `when` arm per constructor.

Instance Method Summary collapse

Constructor Details

#initialize(map) ⇒ ConstructorRegistry

Returns a new instance of ConstructorRegistry.



10
11
12
# File 'lib/dommy/bridge/constructor_registry.rb', line 10

def initialize(map)
  @map = map.freeze
end

Instance Method Details

#[](name) ⇒ Object



14
15
16
# File 'lib/dommy/bridge/constructor_registry.rb', line 14

def [](name)
  @map[name]
end

#key?(name) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/dommy/bridge/constructor_registry.rb', line 18

def key?(name)
  @map.key?(name)
end

#namesObject

The set of constructor names, e.g. for host-side enumeration / tests.



23
24
25
# File 'lib/dommy/bridge/constructor_registry.rb', line 23

def names
  @map.keys
end