Class: ActionController::MiddlewareStack

Inherits:
ActionDispatch::MiddlewareStack show all
Defined in:
lib/action_controller/metal.rb

Overview

Action Controller MiddlewareStack

Extend ActionDispatch middleware stack to make it aware of options allowing the following syntax in controllers:

class PostsController < ApplicationController
  use AuthenticationMiddleware, except: [:index, :show]
end

Defined Under Namespace

Classes: Middleware

Instance Attribute Summary

Attributes inherited from ActionDispatch::MiddlewareStack

#middlewares

Instance Method Summary collapse

Methods inherited from ActionDispatch::MiddlewareStack

#[], #delete, #delete!, #each, #initialize, #initialize_copy, #insert, #insert_after, #last, #move, #move_after, #size, #swap, #unshift, #use

Constructor Details

This class inherits a constructor from ActionDispatch::MiddlewareStack

Instance Method Details

#build(action, app = nil, &block) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/action_controller/metal.rb', line 29

def build(action, app = nil, &block)
  action = action.to_s

  middlewares.reverse.inject(app || block) do |a, middleware|
    middleware.valid?(action) ? middleware.build(a) : a
  end
end