blob: 36acfda52498a4f95f19b10300872e6b614bf3c3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
module ActiveSupport
module LazyLoadHooks
def _setup_base_hooks
@base_hooks ||= Hash.new {|h,k| h[k] = [] }
@base ||= {}
end
def base_hook(name = nil, &block)
_setup_base_hooks
if base = @base[name]
base.instance_eval(&block)
else
@base_hooks[name] << block
end
end
def run_base_hooks(base, name = nil)
_setup_base_hooks
@base_hooks[name].each { |hook| base.instance_eval(&hook) } if @base_hooks
@base[name] = base
end
end
end
|