Class: UriComponentBuidler
- Inherits:
-
Object
- Object
- UriComponentBuidler
- Defined in:
- lib/helper/uri_component_builder.rb
Class Method Summary collapse
Class Method Details
.construct(path, params) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/helper/uri_component_builder.rb', line 2 def self.construct(path, params) path = path.dup path_params = path.split('/').select { |s| s.start_with?(':') }.map { |s| s[1..-1].to_sym } path_params.each do |key| raise ArgumentError, "#{key} should be passed in params" unless params[key] path.sub!(":#{key}", params[key].to_s) params.delete(key) end path.end_with?('/') ? path[0..-2] : path end |