oggy / looksee

Supercharged method introspection in IRB
MIT License
364 stars 14 forks source link

Looksee fails with instances of classes that use the equalizer gem #27

Closed egwspiti closed 10 years ago

egwspiti commented 10 years ago

Let's say we have the following class that uses the equalizer gem:

require 'equalizer'

class GeoLocation
  include Equalizer.new(:latitude, :longitude)

  attr_reader :latitude, :longitude

  def initialize(latitude, longitude)
    @latitude, @longitude = latitude, longitude
  end
end

Looksee fails with objects of this class like this:

2.1.1 :001 > require 'looksee'
 => true 
2.1.1 :002 > x = GeoLocation.new(1,2)
 => #<GeoLocation latitude=1 longitude=2> 
2.1.1 :003 > x.ls
(Object doesn't support #inspect)
 =>  
2.1.1 :004 > x.inspect
 => "#<GeoLocation latitude=1 longitude=2>" 
egwspiti commented 10 years ago

After examining it a little bit more, it seems that it's the following "pattern" that causes the problem:

class X < Module ; end

class Y
  include X.new
end

Using looksee on an instance of Y:

2.1.1 :001 > require 'looksee'
 => true 
2.1.1 :002 > y = Y.new
 => #<Y:0x00000002a68bf8> 
2.1.1 :003 > y.ls
(Object doesn't support #inspect)
 =>  
oggy commented 10 years ago

Just pushed 2.1.1 which should fix this. Thanks for the report!