Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Factory types #191
Is there a way to document that a function yields an instance of the class passed in as a parameter?
module Factoryish def self.with_instance(some_class) the_instance = some_class.new yield the_instance # some more code end end
Thank you for your help.
PS: Amazing, amazing work on this gem and the VS Code extension
That's not possible yet, but I might be able to make it work based on the way that return types are inferred from methods with
module Factoryish # @!macro # @return [$1] def self.make_instance(some_class); end end string = Factoryish.make_instance(String) string # <= Type is String
For a yieldparam, it should look something like this:
module Factoryish # @!macro # @yieldparam [$1] def self.with_instance(some_class) the_instance = some_class.new yield the_instance # some more code end end Factoryish.with_instance(String) do |instance| instance # <= Type is String end
I'll add it to the roadmap.