Class: TipTap::Registry

Inherits:
Object
  • Object
show all
Defined in:
lib/tip_tap/registry.rb

Constant Summary collapse

MissingNodeError =
Class.new(StandardError)

Class Method Summary collapse

Class Method Details

.clearObject



19
20
21
# File 'lib/tip_tap/registry.rb', line 19

def self.clear
  @registry = {}
end

.node_for(name) ⇒ Object



15
16
17
# File 'lib/tip_tap/registry.rb', line 15

def self.node_for(name)
  registry.fetch(name.to_s) { raise MissingNodeError.new("Unknown node type: #{name}") }
end

.register(name, klass) ⇒ Object



11
12
13
# File 'lib/tip_tap/registry.rb', line 11

def self.register(name, klass)
  registry[name.to_s] = klass
end

.registryObject



23
24
25
# File 'lib/tip_tap/registry.rb', line 23

def self.registry
  @registry ||= {}
end