def if_conditions(params_as_string)
cond = []
condition_string = proc do |key, value, regexp_string|
max = Behavior.count_parens_up_to(value.source, value.source.size)
captures = max == 0 ? "" : (1..max).to_a.map{ |n| "#{key}#{n}" }.join(", ") + " = " +
(1..max).to_a.map{ |n| "$#{n}"}.join(", ")
" (#{value.inspect} =~ #{regexp_string}) #{" && (" + captures + ")" unless captures.empty?}"
end
@conditions.each_pair do |key, value|
cond << case key
when :path then condition_string[key, value, "cached_path"]
when :method then condition_string[key, value, "cached_method"]
else condition_string[key, value, "request.#{key}.to_s"]
end
end
if @conditional_block
str = " # #{@conditional_block.inspect.scan(/@([^>]+)/).flatten.first}\n"
str << " (block_result = #{CachedProc.new(@conditional_block)}.call(request, params.merge({#{params_as_string}})))" if @conditional_block
cond << str
end
cond
end