This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
2017-05-30 13:30:06 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-30 01:23:43 -07:00
|
|
|
class StatusFinder
|
2017-05-30 13:30:06 -07:00
|
|
|
attr_reader :url
|
|
|
|
|
|
|
|
def initialize(url)
|
|
|
|
@url = url
|
|
|
|
end
|
|
|
|
|
2017-08-30 01:23:43 -07:00
|
|
|
def status
|
2017-05-30 13:30:06 -07:00
|
|
|
verify_action!
|
|
|
|
|
2017-09-02 08:42:47 -07:00
|
|
|
raise ActiveRecord::RecordNotFound unless TagManager.instance.local_url?(url)
|
|
|
|
|
2017-05-30 13:30:06 -07:00
|
|
|
case recognized_params[:controller]
|
|
|
|
when 'statuses'
|
2017-08-30 01:23:43 -07:00
|
|
|
Status.find(recognized_params[:id])
|
2017-05-30 13:30:06 -07:00
|
|
|
else
|
|
|
|
raise ActiveRecord::RecordNotFound
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def recognized_params
|
|
|
|
Rails.application.routes.recognize_path(url)
|
|
|
|
end
|
|
|
|
|
|
|
|
def verify_action!
|
2023-02-18 03:37:47 -08:00
|
|
|
raise ActiveRecord::RecordNotFound unless recognized_params[:action] == 'show'
|
2017-05-30 13:30:06 -07:00
|
|
|
end
|
|
|
|
end
|