Skip to content

Commit

Permalink
Merge pull request #184 from bdewater/more-presence
Browse files Browse the repository at this point in the history
Annotate remaining hardcoded blank?/present?/presence return values
  • Loading branch information
vinistock authored Oct 30, 2023
2 parents 4403b3c + 4906080 commit 1c29427
Showing 1 changed file with 102 additions and 0 deletions.
102 changes: 102 additions & 0 deletions rbi/annotations/activesupport.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ class ActiveSupport::TimeWithZone
include ::DateAndTime::Zones
# @shim: Methods on ActiveSupport::TimeWithZone are delegated to `Time` using `method_missing
include ::DateAndTime::Calculations

sig { returns(FalseClass) }
def blank?; end

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

# @shim: since `blank?` is always false, `present?` always returns `true`
sig { returns(TrueClass) }
def present?; end
end

class Object
Expand Down Expand Up @@ -157,3 +168,94 @@ class Array
sig { returns(ActiveSupport::ArrayInquirer) }
def inquiry; end
end

class Date
sig { returns(FalseClass) }
def blank?; end

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

# @shim: since `blank?` is always false, `present?` always returns `true`
sig { returns(TrueClass) }
def present?; end
end

class DateTime
sig { returns(FalseClass) }
def blank?; end

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

# @shim: since `blank?` is always false, `present?` always returns `true`
sig { returns(TrueClass) }
def present?; end
end

class NilClass
sig { returns(TrueClass) }
def blank?; end

# @shim: since `present?` is always false, `presence` always returns `nil`
sig { returns(NilClass) }
def presence; end

# @shim: since `blank?` is always true, `present?` always returns `false`
sig { returns(FalseClass) }
def present?; end
end

class FalseClass
sig { returns(TrueClass) }
def blank?; end

# @shim: since `present?` is always false, `presence` always returns `nil`
sig { returns(NilClass) }
def presence; end

# @shim: since `blank?` is always true, `present?` always returns `false`
sig { returns(FalseClass) }
def present?; end
end

class TrueClass
sig { returns(FalseClass) }
def blank?; end

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

# @shim: since `blank?` is always false, `present?` always returns `true`
sig { returns(TrueClass) }
def present?; end
end

class Numeric
sig { returns(FalseClass) }
def blank?; end

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

# @shim: since `blank?` is always false, `present?` always returns `true`
sig { returns(TrueClass) }
def present?; end
end

class Time
sig { returns(FalseClass) }
def blank?; end

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

# @shim: since `blank?` is always false, `present?` always returns `true`
sig { returns(TrueClass) }
def present?; end
end

0 comments on commit 1c29427

Please sign in to comment.