Module: AyeCommander::Shareable::ClassMethods
- Included in:
- Command::ClassMethods
- Defined in:
- lib/aye_commander/shareable.rb
Overview
This module serves to make sure that when included or inherited everything related to the command is preserved Prepend is not really supported, but you really shouldnt be prepending a command so… meh
Instance Method Summary collapse
-
#included(includer) ⇒ Object
This ensures that class methods are extended when Command is included.
-
#inherited(inheriter) ⇒ Object
Rubys object model already links the ancestry path of singleton classes when using classic inheritance so no need to extend.
Instance Method Details
#included(includer) ⇒ Object
This ensures that class methods are extended when Command is included
9 10 11 12 13 14 15 16 17 |
# File 'lib/aye_commander/shareable.rb', line 9 def included(includer) super includer.extend AyeCommander::Command::ClassMethods %i(@limiters @succeeds @hooks).each do |var| if instance_variable_defined? var includer.instance_variable_set var, instance_variable_get(var) end end end |
#inherited(inheriter) ⇒ Object
Rubys object model already links the ancestry path of singleton classes when using classic inheritance so no need to extend. Just need to add the variables to the inheriter.
22 23 24 25 26 27 28 29 |
# File 'lib/aye_commander/shareable.rb', line 22 def inherited(inheriter) super %i(@limiters @succeeds @hooks).each do |var| if instance_variable_defined? var inheriter.instance_variable_set var, instance_variable_get(var) end end end |