class ActionController::MiddlewareStack::Middleware

:nodoc:
:nodoc:
end
use AuthenticationMiddleware, except: [:index, :show]
class PostsController < ApplicationController
allowing the following syntax in controllers:
Extend ActionDispatch middleware stack to make it aware of options

def initialize(klass, *args, &block)

:nodoc:
:nodoc:

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

allowing the following syntax in controllers:
Extend ActionDispatch middleware stack to make it aware of options
def initialize(klass, *args, &block)
  options = args.extract_options!
  @only   = Array(options.delete(:only)).map(&:to_s)
  @except = Array(options.delete(:except)).map(&:to_s)
  args << options unless options.empty?
  super
end

def valid?(action)

def valid?(action)
  if @only.present?
    @only.include?(action)
  elsif @except.present?
    !@except.include?(action)
  else
    true
  end
end