Sha256: 393e7a7fa1e636bdabb1394012b9b4c7034430afecfb1b9f54fa96ccfc4a400e
Contents?: true
Size: 880 Bytes
Versions: 2
Compression:
Stored size: 880 Bytes
Contents
module Pancake module Hooks module OnInherit def self.extended(base) base.class_eval do extlib_inheritable_reader :_on_inherit @_on_inherit = [] end end # Provides an inheritance hook to all extended classes # Allows ou to hook into the inheritance def inherited(base) super _on_inherit.each{|b| b.call(base,self)} end # A hook to add code when the stack is inherited # The code will be executed when the class is inherited # # @example # MyClass.on_inherit do |base, parent| # # do stuff here between the child and parent # end # # @api public # @author Daniel Neighman def on_inherit(&block) _on_inherit << block if block _on_inherit end end # OnInherit end # Hooks end # Pancake
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pancake-0.3.0 | lib/pancake/hooks/on_inherit.rb |
pancake-0.2.0 | lib/pancake/hooks/on_inherit.rb |