Skip to content

Commit

Permalink
Merge pull request #182 from bdewater/as-presence
Browse files Browse the repository at this point in the history
Add annotations for presence/presence_in
  • Loading branch information
KaanOzkan authored Oct 27, 2023
2 parents f20fca3 + 19cb35f commit 710b890
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions rbi/annotations/activerecord.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ class ActiveRecord::Base
sig { returns(FalseClass) }
def blank?; end

# @shim: since `present?` is always true, `presence` always returns `self`
sig { returns(T.self_type) }
def presence; end

sig { returns(TrueClass) }
def present?; end
end
6 changes: 6 additions & 0 deletions rbi/annotations/activesupport.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ class Object
sig { returns(T::Boolean) }
def blank?; end

sig { returns(T.nilable(T.self_type)) }
def presence; end

sig { params(another_object: T.untyped).returns(T.nilable(T.self_type)) }
def presence_in(another_object); end

sig { returns(T::Boolean) }
def present?; end
end
Expand Down

0 comments on commit 710b890

Please sign in to comment.