-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize AttributeTranslator (#2393)
* Add GreedyRoute Define setter methods in AttributeTranslator Combine default route attributes + desc attributes Refactor Pattern Remove description in settings * Add greedy_route_spec.rb Remove delete options * Revert settings description * Rubocop * Remove details and replace spec `details` with detail * Add CHANGELOG.md entry
- Loading branch information
1 parent
274d2bc
commit 63a0416
Showing
11 changed files
with
194 additions
and
103 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
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
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,31 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'grape/router/attribute_translator' | ||
require 'forwardable' | ||
|
||
# Act like a Grape::Router::Route but for greedy_match | ||
# see @neutral_map | ||
|
||
module Grape | ||
class Router | ||
class GreedyRoute | ||
extend Forwardable | ||
|
||
attr_reader :index, :pattern, :options, :attributes | ||
|
||
delegate Grape::Router::AttributeTranslator::ROUTE_ATTRIBUTES => :@attributes | ||
|
||
def initialize(index:, pattern:, **options) | ||
@index = index | ||
@pattern = pattern | ||
@options = options | ||
@attributes = Grape::Router::AttributeTranslator.new(**options) | ||
end | ||
|
||
# Grape::Router:Route defines params as a function | ||
def params(_input = nil) | ||
@attributes.params || {} | ||
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
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
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
Oops, something went wrong.