Class: ActionController::MiddlewareStack::Middleware

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

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from ActionDispatch::MiddlewareStack::Middleware

#args, #block, #classcache, #name

Instance Method Summary (collapse)

Methods inherited from ActionDispatch::MiddlewareStack::Middleware

#==, #build, #inspect, #klass

Constructor Details

- (Middleware) initialize(klass, *args, &block)

:nodoc:



14
15
16
17
18
19
20
# File 'actionpack/lib/action_controller/metal.rb', line 14

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

Instance Method Details

- (Boolean) valid?(action)

Returns:

  • (Boolean)


22
23
24
25
26
27
28
29
30
# File 'actionpack/lib/action_controller/metal.rb', line 22

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