diff --git a/lib/xcake/core_ext/class.rb b/lib/xcake/core_ext/class.rb index 680f2a65..3d468f0a 100644 --- a/lib/xcake/core_ext/class.rb +++ b/lib/xcake/core_ext/class.rb @@ -1,9 +1,14 @@ module Xcake module CoreExtensions - # Returns all descendants of a class + # @example Including in a class + # Class.send(:include, Xcake::CoreExtensions::ClassDescendants) # done with send because of old ruby versions # - def descendants - ObjectSpace.each_object(singleton_class).select { |klass| klass < self } + module ClassDescendants + # Returns all descendants of a class + # + def descendants + ObjectSpace.each_object(singleton_class).select { |klass| klass < self } + end end end end diff --git a/lib/xcake/generator.rb b/lib/xcake/generator.rb index 94d6b7da..87f46232 100644 --- a/lib/xcake/generator.rb +++ b/lib/xcake/generator.rb @@ -3,7 +3,7 @@ class Generator include Dependency include Plugin include Visitor - Class.send(:include, CoreExtensions) # done with send because of old ruby versions + Class.send(:include, CoreExtensions::ClassDescendants) # done with send because of old ruby versions attr_accessor :context diff --git a/spec/core_ext/class_spec.rb b/spec/core_ext/class_spec.rb index 2c461553..8b2efbfd 100644 --- a/spec/core_ext/class_spec.rb +++ b/spec/core_ext/class_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' class Parent - Class.send(:include, Xcake::CoreExtensions) # done with send because of old ruby versions + Class.send(:include, Xcake::CoreExtensions::ClassDescendants) # done with send because of old ruby versions end class Child < Parent