Module: IncludeAll

Defined in:
lib/include_all.rb

Overview

Module declaration

Instance Method Summary collapse

Instance Method Details

#include_all(*args) ⇒ Object

Include all (in the future, a subset) of functionality or classes in a newly-required module

Example require_all ‘module’ include_all



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/include_all.rb', line 13

def include_all(*args)
  added = list_objects()
    (added - $startup).each {
      |m|
      begin
        include m
      rescue TypeError => e
        # Do nothing
       end
    }
  $startup = added
end

#list_objectsObject

Lists objects in the ObjectSpace on demand



27
28
29
# File 'lib/include_all.rb', line 27

def list_objects
  ObjectSpace.each_object(Module).to_a
end