Class: Taro::Rails::NormalizedRoute
- Inherits:
-
Taro::Route
- Object
- Taro::Route
- Taro::Rails::NormalizedRoute
- Defined in:
- lib/taro/rails/normalized_route.rb
Instance Attribute Summary
Attributes inherited from Taro::Route
#endpoint, #openapi_operation_id, #openapi_path, #verb
Instance Method Summary collapse
- #ignored? ⇒ Boolean
-
#initialize(rails_route) ⇒ NormalizedRoute
constructor
A new instance of NormalizedRoute.
Methods inherited from Taro::Route
#can_have_request_body?, #inspect, #path_params
Constructor Details
#initialize(rails_route) ⇒ NormalizedRoute
Returns a new instance of NormalizedRoute.
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/taro/rails/normalized_route.rb', line 4 def initialize(rails_route) action, controller = rails_route.requirements.values_at(:action, :controller) # Journey::Route#verb is a String. Its usually something like 'POST', but # manual matched routes may have e.g. 'GET|POST' (🤢). We only need one copy. verb = rails_route.verb.to_s.scan(/\w+/).sort.last.to_s.downcase openapi_operation_id = "#{verb}_#{action}_#{controller}".gsub('/', '__') openapi_path = rails_route.path.spec.to_s.gsub('(.:format)', '').gsub(/:(\w+)/, '{\1}') endpoint = "#{controller}##{action}" super(endpoint:, openapi_operation_id:, openapi_path:, verb:) end |
Instance Method Details
#ignored? ⇒ Boolean
16 17 18 |
# File 'lib/taro/rails/normalized_route.rb', line 16 def ignored? internal? || patch_update? end |