Skip to content

Commit

Permalink
Merge pull request #33 from ksss/belongs_to-implicitly_returns_nil
Browse files Browse the repository at this point in the history
Support annotation `implicitly-returns-nil`
  • Loading branch information
ksss authored Jan 31, 2025
2 parents 29541de + 607d517 commit 095dab2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/orthoses/active_record/belongs_to.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def call
opt = "#{type}?"

[
"def #{ref.name}: () -> #{opt}",
"%a{implicitly-returns-nil} def #{ref.name}: () -> #{type}",
"def #{ref.name}=: (#{opt}) -> #{opt}",
"def reload_#{ref.name}: () -> #{opt}",
].tap do |ary|
Expand Down
8 changes: 7 additions & 1 deletion lib/orthoses/active_record/belongs_to_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
begin
require 'test_helper'
rescue LoadError
end

module BelongsToTest
LOADER = ->(){
class User < ActiveRecord::Base
Expand Down Expand Up @@ -40,7 +45,8 @@ class BelongsToTest::Post < ::ActiveRecord::Base

expect = <<~RBS
module BelongsToTest::Post::GeneratedAssociationMethods
def user: () -> BelongsToTest::User?
%a{implicitly-returns-nil}
def user: () -> BelongsToTest::User
def user=: (BelongsToTest::User?) -> BelongsToTest::User?
Expand Down

0 comments on commit 095dab2

Please sign in to comment.