Module: Metior::AutoIncludeVCS::ClassMethods

Defined in:
lib/metior/auto_include_vcs.rb

Overview

This module implements the class method inherited that will handle the automatic inclusion of the VCS implementation Module

Author:

  • Sebastian Staudt

Instance Method Summary collapse

Instance Method Details

#inherited(subclass) ⇒ Object

This method will automatically include the VCS implementation Module corresponding to the subclass that has just been defined

Parameters:

  • subclass (Class)

    The subclass that has been defined



31
32
33
34
35
36
37
# File 'lib/metior/auto_include_vcs.rb', line 31

def inherited(subclass)
  vcs = Object
  subclass.to_s.split('::')[0..-2].each do |mod|
    vcs = vcs.const_get mod.to_sym
  end
  subclass.send :include, vcs if vcs.ancestors.include? VCS
end