Class: Protod::Rpc::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/protod/rpc/request.rb

Defined Under Namespace

Classes: Base, Receiver

Class Method Summary collapse

Class Method Details

.clear!Object



25
26
27
# File 'lib/protod/rpc/request.rb', line 25

def clear!
  @map = nil
end

.find_by(ruby_ident) ⇒ Object



17
18
19
# File 'lib/protod/rpc/request.rb', line 17

def find_by(ruby_ident)
  map[Protod::RubyIdent.absolute_of(ruby_ident)]
end

.keysObject



21
22
23
# File 'lib/protod/rpc/request.rb', line 21

def keys
  map.keys
end

.register_for(*ruby_idents, with:, force: true, ignore: false, &body) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/protod/rpc/request.rb', line 5

def register_for(*ruby_idents, with:, force: true, ignore: false, &body)
  ruby_idents.map { Protod::RubyIdent.absolute_of(_1) }.each do |ruby_ident|
    next if map.key?(ruby_ident) && ignore

    raise ArgumentError, "Request already regsitered for #{ruby_ident}" if map.key?(ruby_ident) && !force

    map[ruby_ident] = Class.new(with, &body).tap do |const|
      const.ruby_ident = Protod::RubyIdent.build_from(ruby_ident)
    end
  end
end