Class: Class
- Inherits:
-
Object
- Object
- Class
- Defined in:
- lib/heredity/core_ext/class.rb
Instance Method Summary collapse
Instance Method Details
#inherited(klass) ⇒ Object
2 3 4 5 6 7 8 9 10 |
# File 'lib/heredity/core_ext/class.rb', line 2 def inherited(klass) # Check the class instance variable so we don't eagerly initialize empty # arrays for every class (i.e. object). return if @inherited_hooks.nil? inherited_hooks.each do |block| klass.class_eval(&block) end end |
#inherited_hooks ⇒ Object
12 13 14 |
# File 'lib/heredity/core_ext/class.rb', line 12 def inherited_hooks @inherited_hooks ||= [] end |
#on_inherit(&block) ⇒ Object
16 17 18 |
# File 'lib/heredity/core_ext/class.rb', line 16 def on_inherit(&block) inherited_hooks << block end |