def compiled_params(params = merged_params, placeholders = merged_placeholders)
compiled = {}
params.each_pair do |key, value|
unless value.is_a? String
raise ArgumentError, "param value must be string (#{value.inspect})"
end
result = []
value = value.dup
match = true
while match
if match = SEGMENT_REGEXP_WITH_BRACKETS.match(value)
result << match.pre_match unless match.pre_match.empty?
ph_key = match[1][1..-1].intern
if match[2]
result << "#{ph_key}#{match[3]}""#{ph_key}#{match[3]}"
else
if place = placeholders[ph_key]
result << "#{place[0]}#{place[1]}""#{place[0]}#{place[1]}"
else
raise "Placeholder not found while compiling routes: :#{ph_key}"
end
end
value = match.post_match
elsif match = JUST_BRACKETS.match(value)
result << match.pre_match unless match.pre_match.empty?
result << "path#{match[1]}""path#{match[1]}"
value = match.post_match
else
result << value unless value.empty?
end
end
compiled[key] = Behavior.array_to_code(result).gsub("\\_", "_")
end
compiled
end