Skip to content

Instantly share code, notes, and snippets.

@mischa
Created December 7, 2008 23:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mischa/33279 to your computer and use it in GitHub Desktop.
Save mischa/33279 to your computer and use it in GitHub Desktop.
module ActionController
class MiddlewareStack < Array
class Middleware
attr_reader :klass, :args, :block
def initialize(klass, *args, &block)
@klass = klass.is_a?(Class) ? klass : klass.to_s.constantize
@args = args
@block = block
end
def ==(middleware)
case middleware
when Middleware
klass == middleware.klass
when Class
klass == middleware
else
klass == middleware.to_s.constantize
end
end
def inspect
str = @klass.to_s
@args.each { |arg| str += ", #{arg.inspect}" }
str
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment