Module: Gear::Filters
- Defined in:
- lib/gear/filters.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(mod) ⇒ Object
24 25 26 |
# File 'lib/gear/filters.rb', line 24 def self.included(mod) mod.extend(ClassMethods) end |
.setup(app, *a, &block) ⇒ Object
28 |
# File 'lib/gear/filters.rb', line 28 def self.setup(app, *a, &block) end |
Instance Method Details
#run_filters(type) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/gear/filters.rb', line 30 def run_filters(type) o = self.class.to_s.split("::") filters = Object.const_get(o.first).filters filters[type].each do |filter| if (filter[0].is_a?(Symbol) && (filter[0] == o.last.to_sym || filter[0] == :all)) || (filter[0].is_a?(String) && /^#{filter[0]}\/?$/ =~ @env.REQUEST_URI) self.instance_eval(&filter[1]) end end end |
#service(*a) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/gear/filters.rb', line 41 def service(*a) run_filters(:before) super(*a) run_filters(:after) self end |