-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# typed: strict | ||
# frozen_string_literal: true | ||
|
||
module LunchMoney | ||
module Deprecate | ||
cattr_accessor :endpoint_deprecation_warnings, default: true | ||
|
||
sig { params(replacement: T.nilable(String)).void } | ||
def deprecate_endpoint(replacement = nil) | ||
return unless endpoint_deprecation_warnings | ||
|
||
replacement = if replacement.nil? | ||
"There is currently no replacement for this endpoint" | ||
else | ||
"Please use #{replacement} instead" | ||
end | ||
|
||
message = "#{deprecated_endpoint} is deprecated and may be removed from LunchMoney | #{replacement}" | ||
Kernel.warn(message) | ||
end | ||
|
||
private | ||
|
||
sig { returns(String) } | ||
def deprecated_endpoint | ||
endpoint_call = Kernel.caller_locations.find { |call| call.to_s.include?("lunchmoney/calls") } | ||
|
||
if endpoint_call.nil? | ||
"" | ||
else | ||
"LunchMoney::Api##{endpoint_call.label}" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters