module Doorkeeper::Helpers::Filter::ClassMethods

def doorkeeper_for(*args)

def doorkeeper_for(*args)
  doorkeeper_for = DoorkeeperForBuilder.create_doorkeeper_for(*args)
  before_filter doorkeeper_for.filter_options do
    return if doorkeeper_for.validate_token(doorkeeper_token)
    # TODO: use ErrorRespose class for this
    render_options = doorkeeper_unauthorized_render_options
    if render_options.nil? || render_options.empty?
      head :unauthorized
    else
      render_options[:status] = :unauthorized
      render_options[:layout] = false if render_options[:layout].nil?
      render render_options
    end
  end
end