Module: Genesis::Protocol
- Included in:
- Echo::Protocol, Echo::Server, Http::Protocol, Http::Server, Snmp::Protocol, Snmp::Server
- Defined in:
- lib/genesis/protocol.rb
Overview
Use some metaprogramming to DRY up protocol definition
Class Method Summary collapse
-
.included(base) ⇒ Object
rubocop:disable Metrics/MethodLength.
Class Method Details
.included(base) ⇒ Object
rubocop:disable Metrics/MethodLength
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/genesis/protocol.rb', line 4 def self.included(base) # rubocop:disable Metrics/MethodLength class << base def included(base) protocol = self base.define_singleton_method(:protocol) { protocol.protocol } end def server Kernel.const_get((to_s.split('::')[0..-2] << 'Server').join('::')) end def start_block end end end |