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(base) ⇒ Object
ClassMethods.
Instance Method Summary collapse
-
#run_filter(sym) ⇒ Object
TODO skip ::I and handle :except :).
-
#service(*a) ⇒ Object
params to controllers, ids n stuff.
Class Method Details
.included(base) ⇒ Object
ClassMethods
37 38 39 |
# File 'lib/tarpaulin/camping/filter.rb', line 37 def self.included(base) base.extend(ClassMethods) # both are class methods, but what Object is @hooks an instance variable of? end |
Instance Method Details
#run_filter(sym) ⇒ Object
TODO skip ::I and handle :except :)
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/tarpaulin/camping/filter.rb', line 43 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
56 57 58 59 60 61 62 63 64 |
# File 'lib/tarpaulin/camping/filter.rb', line 56 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 |