class Padrino::Filter

@private

def apply?(request)

def apply?(request)
  detect = @args.any? do |arg|
    case arg
    when Symbol then request.route_obj && (request.route_obj.named == arg or request.route_obj.named == [@scoped_controller, arg].flatten.join("_").to_sym)
    else             arg === request.path_info
    end
  end || @options.any? do |name, val|
    case name
    when :agent then val === request.user_agent
    else             val === request.send(name)
    end
  end
  detect ^ !@mode
end

def initialize(mode, scoped_controller, options, args, &block)

def initialize(mode, scoped_controller, options, args, &block)
  @mode, @scoped_controller, @options, @args, @block = mode, scoped_controller, options, args, block
end

def to_proc

def to_proc
  if @args.empty? && @options.empty?
    block
  else
    filter = self
    proc { instance_eval(&filter.block) if filter.apply?(request) }
  end
end