Skip to content

Instantly share code, notes, and snippets.

@metaskills
Created June 11, 2010 23:38
Show Gist options
  • Save metaskills/435194 to your computer and use it in GitHub Desktop.
Save metaskills/435194 to your computer and use it in GitHub Desktop.
# 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