Module: JA2R::KlassRegistry
Instance Method Summary collapse
Instance Method Details
#instantiate(hash, options) ⇒ Object
5 6 7 8 9 |
# File 'lib/ja2r/klass_registry.rb', line 5 def instantiate(hash, ) return unless hash&.key? 'type' lookup(hash['type']).new(hash, ) end |
#lookup(type) ⇒ Object
11 12 13 |
# File 'lib/ja2r/klass_registry.rb', line 11 def lookup(type) registry.fetch(type) { Element } end |
#register(type, klass) ⇒ Object
15 16 17 |
# File 'lib/ja2r/klass_registry.rb', line 15 def register(type, klass) registry[type] = klass end |