7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/phpfaker/url_for.rb', line 7
def self.included(base)
suffix = base.name.underscore.gsub('/', '_') base.send :define_method, :"url_for_with_php_fake_#{suffix}" do |*options|
options = options.first
url = send :"url_for_without_php_fake_#{suffix}", options
if (uri = URI(URI.escape(url.to_s)) rescue nil) &&
(uri.scheme.nil? || uri.scheme.start_with?('http')) &&
! Phpfaker::Utils.appended_php_suffix?(uri)
Phpfaker::Utils.append_php_suffix uri
URI.unescape uri.to_s
else
url
end
end
base.alias_method_chain :url_for, :"php_fake_#{suffix}"
end
|