module CampingHooks
include the CampingHooks
module in TheApp
Public Class Methods
included(base)
click to toggle source
# 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
Public Instance Methods
run_filter(sym)
click to toggle source
TODO skip ::I and handle :except :)
# 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)
click to toggle source
Calls superclass method
# 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