Module: Pancake::Hooks::OnInherit
- Included in:
- Stack
- Defined in:
- lib/pancake/hooks/on_inherit.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#inherited(base) ⇒ Object
Provides an inheritance hook to all extended classes Allows ou to hook into the inheritance.
-
#on_inherit(&block) ⇒ Object
A hook to add code when the stack is inherited The code will be executed when the class is inherited.
Class Method Details
.extended(base) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/pancake/hooks/on_inherit.rb', line 4 def self.extended(base) base.class_eval do extlib_inheritable_reader :_on_inherit @_on_inherit = [] end end |
Instance Method Details
#inherited(base) ⇒ Object
Provides an inheritance hook to all extended classes Allows ou to hook into the inheritance
13 14 15 16 |
# File 'lib/pancake/hooks/on_inherit.rb', line 13 def inherited(base) super _on_inherit.each{|b| b.call(base,self)} end |
#on_inherit(&block) ⇒ Object
A hook to add code when the stack is inherited The code will be executed when the class is inherited
28 29 30 31 |
# File 'lib/pancake/hooks/on_inherit.rb', line 28 def on_inherit(&block) _on_inherit << block if block _on_inherit end |