Module: Bones::RPC::Adapter

Extended by:
Adapter
Included in:
Adapter
Defined in:
lib/bones/rpc/adapter.rb,
lib/bones/rpc/adapter/base.rb,
lib/bones/rpc/adapter/json.rb,
lib/bones/rpc/adapter/erlang.rb,
lib/bones/rpc/adapter/parser.rb,
lib/bones/rpc/adapter/msgpack.rb

Defined Under Namespace

Modules: Base, Erlang, JSON, MessagePack Classes: Parser

Instance Method Summary collapse

Instance Method Details

#get(adapter_name) ⇒ Object


7
8
9
# File 'lib/bones/rpc/adapter.rb', line 7

def get(adapter_name)
  adapters[adapter_name] || raise(Errors::InvalidAdapter, "Unknown adapter #{adapter_name.inspect}")
end

#get_by_ext_head(head) ⇒ Object


11
12
13
# File 'lib/bones/rpc/adapter.rb', line 11

def get_by_ext_head(head)
  ext_heads[head] || raise(Errors::InvalidExtMessage, "Unknown adapter for ext head #{head.inspect}")
end

#register(adapter) ⇒ Object


15
16
17
18
19
20
21
22
23
# File 'lib/bones/rpc/adapter.rb', line 15

def register(adapter)
  adapter.send(:attr_reader, :adapter_name)
  adapter.send(:include, Adapter::Base)
  adapter.send(:extend, adapter)
  adapters[adapter] ||= adapter
  adapters[adapter.adapter_name] ||= adapter
  adapters[adapter.adapter_name.to_s] ||= adapter
  return adapter
end

#register_ext_head(adapter, head) ⇒ Object


25
26
27
28
# File 'lib/bones/rpc/adapter.rb', line 25

def register_ext_head(adapter, head)
  ext_heads[head] ||= adapter
  return adapter
end