module Roda::RodaPlugins::Hooks::ClassMethods
def after(&block)
def after(&block) opts[:after_hooks] << define_roda_method("after_hook", 1, &block) if opts[:after_hooks].length == 1 class_eval("alias _roda_after_80__hooks #{opts[:after_hooks].first}", __FILE__, __LINE__) else class_eval("def _roda_after_80__hooks(res) #{opts[:after_hooks].map{|m| "#{m}(res)"}.join(';')} end", __FILE__, __LINE__) end private :_roda_after_80__hooks def_roda_after nil end
def before(&block)
def before(&block) opts[:before_hooks].unshift(define_roda_method("before_hook", 0, &block)) if opts[:before_hooks].length == 1 class_eval("alias _roda_before_10__hooks #{opts[:before_hooks].first}", __FILE__, __LINE__) else class_eval("def _roda_before_10__hooks; #{opts[:before_hooks].join(';')} end", __FILE__, __LINE__) end private :_roda_before_10__hooks def_roda_before nil end
def freeze
def freeze opts[:after_hooks].freeze opts[:before_hooks].freeze super end