Sha256: ef3d917dcf1249c676930787e29161657d5504214f5f64a4097eba33fc531a4e
Contents?: true
Size: 740 Bytes
Versions: 6
Compression:
Stored size: 740 Bytes
Contents
# frozen_string_literal: true require 'active_support/dependencies' module ActiveModelCachers::Hook module Depdenencies def onload(const_name, &block) const = const_name if not const_name.is_a?(String) if const or Module.const_defined?(const_name) (const || const_name.constantize).instance_exec(&block) else load_hooks[const_name].push(block) end end def load_hooks @load_hooks ||= Hash.new{|h, k| h[k] = [] } end def new_constants_in(*) new_constants = super.each{|s| load_hooks[s].each{|hook| s.constantize.instance_exec(&hook) } } return new_constants end end end ActiveSupport::Dependencies.send(:extend, ActiveModelCachers::Hook::Depdenencies)
Version data entries
6 entries across 6 versions & 1 rubygems