Sha256: 7ab301e6b0beea397d2e06698c94199c324ce956ece1cd9b2c37b89824a16c78

Contents?: true

Size: 929 Bytes

Versions: 71

Compression:

Stored size: 929 Bytes

Contents

# frozen-string-literal: true

#
class Roda
  module RodaPlugins
    # The direct_call plugin makes the call class method skip the middleware stack
    # (app.call will still call the middleware).
    # This can be used as an optimization, as the Roda class itself can be used
    # as the callable, which is faster than using a lambda.
    module DirectCall
      def self.configure(app)
        app.send(:build_rack_app)
      end

      module ClassMethods
        # Call the application without middlware.
        def call(env)
          new(env)._roda_handle_main_route
        end

        private

        # If new_api is true, use the receiver as the base rack app for better
        # performance.
        def base_rack_app_callable(new_api=true)
          if new_api
            self
          else
            super
          end
        end
      end
    end

    register_plugin(:direct_call, DirectCall)
  end
end

Version data entries

71 entries across 71 versions & 1 rubygems

Version Path
roda-3.88.0 lib/roda/plugins/direct_call.rb
roda-3.87.0 lib/roda/plugins/direct_call.rb
roda-3.86.0 lib/roda/plugins/direct_call.rb
roda-3.85.0 lib/roda/plugins/direct_call.rb
roda-3.84.0 lib/roda/plugins/direct_call.rb
roda-3.83.0 lib/roda/plugins/direct_call.rb
roda-3.82.0 lib/roda/plugins/direct_call.rb
roda-3.81.0 lib/roda/plugins/direct_call.rb
roda-3.79.0 lib/roda/plugins/direct_call.rb
roda-3.78.0 lib/roda/plugins/direct_call.rb
roda-3.77.0 lib/roda/plugins/direct_call.rb
roda-3.76.0 lib/roda/plugins/direct_call.rb
roda-3.75.0 lib/roda/plugins/direct_call.rb
roda-3.74.0 lib/roda/plugins/direct_call.rb
roda-3.73.0 lib/roda/plugins/direct_call.rb
roda-3.72.0 lib/roda/plugins/direct_call.rb
roda-3.71.0 lib/roda/plugins/direct_call.rb
roda-3.70.0 lib/roda/plugins/direct_call.rb
roda-3.69.0 lib/roda/plugins/direct_call.rb
roda-3.68.0 lib/roda/plugins/direct_call.rb