Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Module.include? behaves oddly #292

Closed
postmodern opened this Issue · 2 comments

2 participants

@postmodern

I just noticed a difference in how Module.include? behaves, comapred to MRI. Module.include? claims that any module includes itself. I can see this behave being expected for Module.is_a? or Module.kind_of?. However, include? should only return true if the given Module was included into the ancestors stack, using the Class.include method.

Example script:

module Mixin
end

class Base
  include Mixin
end

class SuperClass < Base
end

puts "SuperClass includes Mixin" if SuperClass.include?(Mixin)
puts "Base includes Mixin" if Base.include?(Mixin)
puts "Mixin includes Mixin" if Mixin.include?(Mixin)

On Ruby 1.9.1:

$ ruby test_module_included.rb
SuperClass includes Mixin
Base includes Mixin

On JRuby 1.5.0:

$ rvm use jruby
$ ruby test_module_included.rb
SuperClass includes Mixin
Base includes Mixin

On Rubinius 1.0:

$ rbx test_module_included.rb 
SuperClass includes Mixin
Base includes Mixin
Mixin includes Mixin
@kronos
Collaborator

Spec & patch http://gist.github.com/402214 will be committed after reviewing core team

@kronos
Collaborator

Fix edge case for Module#include?. Closed by d3efd7b.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.