Module: Twirp::Rails

Defined in:
lib/twirp/rails.rb,
lib/twirp/rails/engine.rb,
lib/twirp/rails/handler.rb,
lib/twirp/rails/version.rb,
lib/twirp/rails/callbacks.rb,
lib/twirp/rails/rescuable.rb,
lib/twirp/rails/dispatcher.rb,
lib/twirp/rails/configuration.rb,
lib/twirp/rails/rack/conditional_post.rb

Defined Under Namespace

Modules: Callbacks, Rack, Rescuable Classes: Configuration, Dispatcher, Engine, Error, Handler

Constant Summary collapse

VERSION =
"1.2.0"

Class Method Summary collapse

Class Method Details

.servicesObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/twirp/rails/engine.rb', line 36

def services
  if @services.nil?
    ::Rails.application.config.twirp.load_paths.each do |directory|
      ::Rails.root.glob("#{directory}/**/*_twirp.rb").sort.each { |file| require file }
    end

    @services = Twirp::Service.subclasses.map(&:new)

    # Install hooks that may be defined in the config
    @services.each do |service|
      ::Rails.application.config.twirp.service_hooks.each do |hook_name, hook|
        service.send(hook_name, &hook)
      end
    end
  end

  @services
end