aboutsummaryrefslogblamecommitdiffstats
path: root/activesupport/lib/active_support/lazy_load_hooks.rb
blob: 642a4c105c8f87d213a203f191cb0e62dabcf5a7 (plain) (tree)
1
2
3
4
5
6
7
8
9
                    

                                           
 




                                
       
     
 


                                                               

     
module ActiveSupport
  @load_hooks = Hash.new {|h,k| h[k] = [] }
  @loaded = {}

  def self.on_load(name, &block)
    if base = @loaded[name]
      base.instance_eval(&block)
    else
      @load_hooks[name] << block
    end
  end

  def self.run_load_hooks(name, base = Object)
    @load_hooks[name].each { |hook| base.instance_eval(&hook) }
    @loaded[name] = base
  end
end