Guest User

Untitled

a guest
May 23rd, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. module Filter
  2. module ClassMethods
  3. def before_filter(sym, *only)
  4. only.each do |method|
  5. module_eval <<-END
  6. def #{method}_with_before_filter(*args, &block)
  7. send :#{sym}
  8. send :#{method}_without_before_filter, *args, &block
  9. end
  10. alias_method :"#{method}_without_before_filter", :#{method}
  11. alias_method :#{method}, :"#{method}_with_before_filter"
  12. END
  13. end
  14. end
  15. end
  16.  
  17. def self.included(mod)
  18. mod.send :extend, ClassMethods
  19. end
  20. end
Add Comment
Please, Sign In to add comment