yard-contracts icon indicating copy to clipboard operation
yard-contracts copied to clipboard

Class methods showing up as instance methods

Open nixpulvis opened this issue 9 years ago • 1 comments

Doing the following doesn't work as expected.

class Foo
  include Contracts

  class << self
    Contract String => Num
    def foo(a)
      1
    end
  end
end

Shows the method as an instance method.

nixpulvis avatar May 27 '15 20:05 nixpulvis

The current check for whether it's a class or instance method is very simplistic based on there being a self. so this other syntax doesn't work. YARD / Ripper don't (that I could find) provide a way to automatically see if a method is class or instance, hence the need for this hack.

I don't really know what to do to fix it. I don't particularly want to add even bigger hacks for all the edge cases. If you can find an elegant way to do it though I'm open to a pull request.

sfcgeorge avatar Jul 22 '15 17:07 sfcgeorge