Some method calls with blocks implicitly defines a class/module or switch the method definition context. One of the most popular example would be ActiveSupport::Concern.
module Foo
extend ActiveSupport::Concern
class_methods do
def foo = 123
end
end
The #class_methods defines ClassMethods module that will be extend-ed into a class/module where Foo is include-ed.
To support the coding pattern, rbs-inline introduces @rbs class and @rbs module annotations.
module Foo
extend ActiveSupport::Concern
# @rbs module ClassMethods
class_methods do
# @rbs () -> Integer
def foo = 123
end
end
The @rbs module annotation attached to class_methods call defines a module called ClassMethods and put the method definitions inside the module.
# output
module Foo
module ClassMethods
def foo: () -> Integer
end
end
Some method calls with blocks implicitly defines a class/module or switch the method definition context. One of the most popular example would be
ActiveSupport::Concern
.The
#class_methods
definesClassMethods
module that will beextend
-ed into a class/module whereFoo
isinclude
-ed.To support the coding pattern,
rbs-inline
introduces@rbs class
and@rbs module
annotations.The
@rbs module
annotation attached toclass_methods
call defines a module calledClassMethods
and put the method definitions inside the module.