Skip to content
This repository was archived by the owner on Sep 21, 2021. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/rails_sunset/controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def sunset_method(method, datetime, link: nil)
def sunset(datetime, link: nil, only: nil)
after_action(only: only) do |controller|
datetime = normalize_datetime(datetime)
link = normalize_link(link, params)
link = normalize_link(link)
user_agent = request.headers['User-Agent']

# Shove a deprecation warning into the console or wherever it goes
Expand Down Expand Up @@ -44,11 +44,11 @@ def normalize_datetime(datetime)
raise TypeError, 'The date should be a Date, DateTime, Time or string containing a valid date and time'
end

def normalize_link(link, _params)
def normalize_link(link)
link = instance_exec(&(link)) if link.respond_to? :call
return if link.nil?
return link if link.is_a? String
raise TypeError, 'The link should be a string, or a lambda that returns a string'
raise TypeError, 'The link should be a string, or a proc/lambda that returns a string'
end
end
end