Method: Addressable::Template#expand
- Defined in:
- lib/addressable/template.rb
#expand(mapping, processor = nil, normalize_values = true) ⇒ Addressable::URI
Expands a URI template into a full URI.
The object should respond to either the validate or transform messages or both. Both the validate and transform methods should take two parameters: name and value. The validate method should return true or false; true if the value of the variable is valid, false otherwise. An InvalidTemplateValueError exception will be raised if the value is invalid. The transform method should return the transformed variable value as a String. If a transform method is used, the value will not be percent encoded automatically. Unicode normalization will be performed both before and after sending the value to the transform method.
591 592 593 594 595 596 597 598 |
# File 'lib/addressable/template.rb', line 591 def (mapping, processor=nil, normalize_values=true) result = self.pattern.dup mapping = normalize_keys(mapping) result.gsub!( EXPRESSION ) do |capture| transform_capture(mapping, capture, processor, normalize_values) end return Addressable::URI.parse(result) end |