Module: Arf::Proto::Registry

Defined in:
lib/arf/proto/registry.rb

Class Method Summary collapse

Class Method Details

.find(id) ⇒ Object



21
22
23
24
# File 'lib/arf/proto/registry.rb', line 21

def self.find(id)
  @structs ||= {}
  @structs[id]
end

.register!(cls) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/arf/proto/registry.rb', line 6

def self.register!(cls)
  @structs ||= {}
  id = cls.arf_struct_id
  fields = Proto.fields_from_struct(cls)
  @structs[id] = {
    id:,
    fields:,
    type: cls
  }
end

.reset!Object



17
18
19
# File 'lib/arf/proto/registry.rb', line 17

def self.reset!
  @structs = {}
end