Class: Twirp::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/twirp/rails.rb,
lib/twirp/rails/engine.rb

Instance Method Summary collapse

Constructor Details

#initialize(handler = nil) ⇒ Service

Returns a new instance of Service.



26
27
28
29
# File 'lib/twirp/rails.rb', line 26

def initialize(handler = nil)
  handler ||= Twirp::Rails::Dispatcher.new(self.class)
  original_initialize(handler)
end

Instance Method Details

#inspectObject

Override inspect to show all available RPCs This is used when displaying routes.



61
62
63
# File 'lib/twirp/rails/engine.rb', line 61

def inspect
  self.class.rpcs.map { |rpc| "#{self.class.name.demodulize.underscore}_handler##{rpc[1][:ruby_method]}" }.join("\n")
end

#original_initializeObject

Override initialize to make handler argument optional. When left nil, we will use our dispatcher.



25
# File 'lib/twirp/rails.rb', line 25

alias_method :original_initialize, :initialize