Module: Rango::FiltersMixin::ClassMethods
- Defined in:
- lib/rango/mixins/filters.rb
Instance Method Summary collapse
- #after(action = nil, options = Hash.new, &block) ⇒ Object
- #after_filters ⇒ Object
-
#before(action = nil, options = Hash.new, &block) ⇒ Object
before :login before :login, except: [:send].
-
#before_filters ⇒ Object
we can’t use class variables because they are shared between parent and child classes.
- #get_filters(type) ⇒ Object
-
#inherited(subclass) ⇒ Object
If you are using your own inherited hook, you have to use super here, otherwise your filters won’t work!.
Instance Method Details
#after(action = nil, options = Hash.new, &block) ⇒ Object
64 65 66 |
# File 'lib/rango/mixins/filters.rb', line 64 def after(action = nil, = Hash.new, &block) self.after_filters[action || block] = end |
#after_filters ⇒ Object
52 53 54 |
# File 'lib/rango/mixins/filters.rb', line 52 def after_filters @after_filters ||= Hash.new end |
#before(action = nil, options = Hash.new, &block) ⇒ Object
before :login before :login, except: [:send]
59 60 61 |
# File 'lib/rango/mixins/filters.rb', line 59 def before(action = nil, = Hash.new, &block) self.before_filters[action || block] = end |
#before_filters ⇒ Object
we can’t use class variables because they are shared between parent and child classes
47 48 49 |
# File 'lib/rango/mixins/filters.rb', line 47 def before_filters @before_filters ||= Hash.new end |
#get_filters(type) ⇒ Object
69 70 71 |
# File 'lib/rango/mixins/filters.rb', line 69 def get_filters(type) self.send("#{type}_filters") end |
#inherited(subclass) ⇒ Object
If you are using your own inherited hook, you have to use super here, otherwise your filters won’t work!
38 39 40 41 42 |
# File 'lib/rango/mixins/filters.rb', line 38 def inherited(subclass) subclass.before_filters.replace(self.before_filters) subclass.after_filters.replace(self.after_filters) super end |