Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial

  • Loading branch information...
commit ae549d5d174022a37ee89a77aa3929d536220d94 0 parents
@nuex authored
Showing with 28 additions and 0 deletions.
  1. +1 −0  init.rb
  2. +27 −0 lib/filter_hacks.rb
1  init.rb
@@ -0,0 +1 @@
+ApplicationController.send :include, FilterHacks
27 lib/filter_hacks.rb
@@ -0,0 +1,27 @@
+module FilterHacks
+
+ def self.included kls
+ kls.send :extend, ClassMethods
+ end
+
+ module ClassMethods
+
+ # Find a previously created filter and add
+ # some more options to it.
+ #
+ # Usage:
+ # <tt>append_filter_options :my_filter_method, :only => [:index]</tt>
+ #
+ def append_filter_options method, options
+ filter = filter_chain.select{ |f| f.method == method }.first
+ if filter
+ current_options = filter.instance_variable_get('@options')
+ options.each_key do |k|
+ actions = options[k].to_a.map! { |o| o.to_s }
+ current_options[k].merge(actions)
+ end
+ end
+ end
+ end
+
+end
Please sign in to comment.
Something went wrong with that request. Please try again.