Created
September 4, 2018 11:48
-
-
Save lucaschain/f8b2d7928e3a89eed8c9b7cdeef29572 to your computer and use it in GitHub Desktop.
Path splitting example in ruby
This file contains hidden or 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
path = "api/auto/refinancing_empirica/result" | |
exp = /^api\/([a-z_]+)\/([a-z_]+)/ | |
matched_params = exp.match(path) do |matches| | |
{ | |
:product => matches[1].to_sym, | |
:modality => matches[2].to_sym | |
} | |
end | |
return if matched_params.nil? | |
params.merge!(matched_params) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment