Module: CampingHooks
- Defined in:
- lib/tarpaulin/camping/filter.rb
Overview
include the CampingHooks module in TheApp
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(mod) ⇒ Object
ClassMethods.
Instance Method Summary collapse
- #run_filter(sym) ⇒ Object
-
#service(*a) ⇒ Object
params to controllers, ids n stuff.
Class Method Details
.included(mod) ⇒ Object
ClassMethods
38 39 40 |
# File 'lib/tarpaulin/camping/filter.rb', line 38 def self.included(mod) mod.extend(ClassMethods) # both are class methods, but what Object is @hooks an instance variable of? end |
Instance Method Details
#run_filter(sym) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/tarpaulin/camping/filter.rb', line 42 def run_filter(sym) o = self.class.to_s.split("::") app = Object.const_get(o.first) filters = app.get_hooks app.set_hook_key(sym) filters[sym].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
params to controllers, ids n stuff
55 56 57 58 59 60 61 62 63 |
# File 'lib/tarpaulin/camping/filter.rb', line 55 def service(*a) # params to controllers, ids n stuff override_self = catch(:halt) do run_filter(:before_service) override_self = super(*a) run_filter(:after_service) override_self end override_self end |