1
2
3
4
5
6
7
8
9
10
11
12
13
14
  def append_features_cv(other)
    # So, the protocol here is that when including +self+ into +target+
    # we also include all modules that are included into +self+.

    hierarchy = other.superclass_chain

    superclass_chain.reverse_each do |ancestor|
      if ancestor.instance_of? IncludedModule and not hierarchy.include? ancestor.module
        IncludedModule.new(ancestor.module).attach_to other
      end
    end

    IncludedModule.new(self).attach_to other
  end