Class: ActionDispatch::Journey::Format
Do not use. This class is for internal use only.
| Relationships & Source Files | |
| Namespace Children | |
|
Classes:
| |
| Inherits: | Object |
| Defined in: | actionpack/lib/action_dispatch/journey/visitors.rb |
Constant Summary
-
ESCAPE_PATH =
# File 'actionpack/lib/action_dispatch/journey/visitors.rb', line 9ActiveSupport::Ractors.shareable_lambda { |value| Router::Utils.escape_path(value) }
-
ESCAPE_SEGMENT =
# File 'actionpack/lib/action_dispatch/journey/visitors.rb', line 10ActiveSupport::Ractors.shareable_lambda { |value| Router::Utils.escape_segment(value) }
Class Method Summary
Instance Method Summary
- #evaluate(hash)
-
#add_to(buffer, hash)
protected
Appends this format's expansion to
buffer- or nothing at all when a parameter is missing, which is how an optional group whose parameter is absent drops out of the generated path.
Constructor Details
.new(parts) ⇒ Format
Class Method Details
.required_path(symbol)
[ GitHub ]# File 'actionpack/lib/action_dispatch/journey/visitors.rb', line 16
def self.required_path(symbol) Parameter.new symbol, ESCAPE_PATH end
.required_segment(symbol)
[ GitHub ]# File 'actionpack/lib/action_dispatch/journey/visitors.rb', line 20
def self.required_segment(symbol) Parameter.new symbol, ESCAPE_SEGMENT end
Instance Method Details
#add_to(buffer, hash) (protected)
Appends this format's expansion to buffer - or nothing at all when
a parameter is missing, which is how an optional group whose
parameter is absent drops out of the generated path. Building into a
shared buffer avoids the intermediate arrays and strings a
join-based evaluation allocates on every generated URL.
# File 'actionpack/lib/action_dispatch/journey/visitors.rb', line 50
protected def add_to(buffer, hash) @parameters.each do |index| return if hash[@parts[index].name].nil? end @parts.each do |part| case part when String buffer << part when Journey::Format part.add_to(buffer, hash) else buffer << part.escape(hash[part.name]) end end end
#evaluate(hash)
[ GitHub ]# File 'actionpack/lib/action_dispatch/journey/visitors.rb', line 39
def evaluate(hash) buffer = +"" add_to(buffer, hash) buffer end