$__filters__ = {} def before_filter( action, opts = {} ) $__filters__[action] = opts end module Bivouac::Filters def service(*a) current_class_name = self.class.name #.to_s.gsub( /.*::/, '' ) apply_filter = nil $__filters__.each do |k, v| if v.size > 0 v.each do |only_or_except, klasses| kklasses = klasses.map{|_| _.name} if only_or_except == :only and kklasses.include?( current_class_name ) apply_filter = k end if only_or_except == :except and not kklasses.include?( current_class_name ) apply_filter = k end end else apply_filter = k end end s = super(*a) unless apply_filter.nil? r = apply_filter.filter( @state ) unless r.nil? redirect r end end s end end