module Redwood
class HookManager
- ## there's probably a better way to do this, but to evaluate a hook
- ## with a bunch of pre-set "local variables" i define a function
- ## per variable and then instance_evaluate the code.
- ##
- ## how does rails do it, when you pass :locals into a partial?
- ##
- ## i don't bother providing setters, since i'm pretty sure the
- ## charade will fall apart pretty quickly with respect to scoping.
- ## "fail-fast", we'll call it.
class HookContext
def initialize name
@__say_id = nil
end
attr_writer :__locals
-
- ## an annoying gotcha here is that if you try something
- ## like var = var.foo(), var will magically get allocated
- ## to Nil and method_missing will never get called. You
- ## can work around this by calling self.var or simply
- ## not assigning it to itself.
def method_missing m, *a
case @__locals[m]
when Proc
Executes before a string search is applied to the index,
returning a new search string.
Variables:
- subs: The string being searched. Be careful about shadowing:
- this variable is actually a method, so use a temporary variable
- or explicitly call self.subs; the substitutions in index.rb
- don't actually work.
+ subs: The string being searched.
EOS
## these two accessors should ONLY be used by single-threaded programs.