Class: ActionController::MiddlewareStack::Middleware

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

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from ActionDispatch::MiddlewareStack::Middleware

#args, #block

Instance Method Summary collapse

Methods inherited from ActionDispatch::MiddlewareStack::Middleware

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

Constructor Details

#initialize(klass, *args, &block) ⇒ Middleware

:nodoc:



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

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

#valid?(action) ⇒ Boolean

Returns:

  • (Boolean)


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

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