123456789_123456789_123456789_123456789_123456789_

Class: ActionDispatch::Journey::Format

Relationships & Source Files
Namespace Children
Classes:
Inherits: Object
Defined in: actionpack/lib/action_dispatch/journey/visitors.rb

Constant Summary

Class Method Summary

Instance Method Summary

Constructor Details

.new(parts) ⇒ Format

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/journey/visitors.rb', line 21

def initialize(parts)
  @parts      = parts
  @children   = []
  @parameters = []

  parts.each_with_index do |object,i|
    case object
    when Journey::Format
      @children << i
    when Parameter
      @parameters << i
    end
  end
end

Class Method Details

.required_path(symbol)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/journey/visitors.rb', line 13

def self.required_path(symbol)
  Parameter.new symbol, ESCAPE_PATH
end

.required_segment(symbol)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/journey/visitors.rb', line 17

def self.required_segment(symbol)
  Parameter.new symbol, ESCAPE_SEGMENT
end

Instance Method Details

#evaluate(hash)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/journey/visitors.rb', line 36

def evaluate(hash)
  parts = @parts.dup

  @parameters.each do |index|
    param = parts[index]
    value = hash[param.name]
    return ''.freeze unless value
    parts[index] = param.escape value
  end

  @children.each { |index| parts[index] = parts[index].evaluate(hash) }

  parts.join
end