Sha256: 14337e388463d236fc7f08bbdbd20051bcc08be74898c098c912eb9d55093d5b
Contents?: true
Size: 963 Bytes
Versions: 1
Compression:
Stored size: 963 Bytes
Contents
module MPatch module ClassAndModule def mixin_ancestors(include_ancestors=true) ancestors.take_while {|a| include_ancestors || a != superclass }. select {|ancestor| ancestor.instance_of?( ::Module ) } end def inherited_by *args if args.empty? args.push(::Class) args.push(::Module) end return_array= [] args.each do |type_name| ::ObjectSpace.each_object(type_name) do |candidate| begin if !return_array.include?(candidate) && candidate != self case self.class.to_s when "Module" return_array.push candidate if candidate.mixin_ancestors.include?(self) when "Class" return_array.push candidate if candidate < self end end rescue ::ArgumentError, ::NoMethodError end end end return_array end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mpatch-2.2.1 | lib/mpatch/class_and_module.rb |