Created
June 11, 2010 23:38
-
-
Save metaskills/435194 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Assume ApplicationController has the filters setup that you see in | |
# BEFORE_FILTERS. Also assume you have mixed in MyControllerFilters into | |
# application controller so you can use all its class/instance methods. | |
module MyControllerFilters | |
BEFORE_FILTERS = [ | |
:shoot_zombies, | |
:set_timezone, | |
:authorize_request, | |
].freeze | |
def self.included(klass) | |
klass.extend ClassMethods | |
klass.send :include, InstanceMethods | |
end | |
module ClassMethods | |
def all_before_filters | |
MyControllerFilters::BEFORE_FILTERS | |
end | |
def skip_all_before_filters | |
all_before_filters.each do |bf| | |
skip_before_filter bf | |
end | |
end | |
end | |
module InstanceMethods | |
end | |
end | |
class ApiController < ApplicationController | |
skip_all_before_filters # Would skip all. | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment