Module: Cuprum::Rails::Controllers::ClassMethods::Middleware
- Defined in:
- lib/cuprum/rails/controllers/class_methods/middleware.rb
Overview
Provides a DSL for defining controller middleware.
Instance Method Summary collapse
Instance Method Details
#middleware ⇒ Array<Cuprum::Rails::Controllers::Middleware> #middleware(command, except: [], only: {]}) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/cuprum/rails/controllers/class_methods/middleware.rb', line 26 def middleware(command = nil, except: [], only: []) unless command.nil? own_middleware << build_middleware(command: command, except: except, only: only) end ancestors .select { |ancestor| ancestor.respond_to?(:own_middleware) } .reverse_each .map(&:own_middleware) .reduce(&:+) end |
#own_middleware ⇒ Object
40 41 42 |
# File 'lib/cuprum/rails/controllers/class_methods/middleware.rb', line 40 def own_middleware @own_middleware ||= [] end |