module PostEmAll::ViewHelpers
Public Instance Methods
link_to(*args, &block)
click to toggle source
# File lib/post-em-all.rb, line 66 def link_to(*args, &block) if block_given? options = args.first || {} html_options = args.second link_to(capture(&block), options, html_options) else name = args[0] options = args[1] || {} html_options = args[2] || {} prevent_post = html_options.delete(:post)===false if !prevent_post && post? is_get = html_options.empty? || !html_options.keys.include?(:method) || html_options[:method] == :get html_options[:method] = :post if is_get html_options = convert_options_to_data_attributes(options, html_options) url = url_for(options) if is_get && !url.match(/^\w+\:/) if url =~ /^https?\:\/\// #url y url host, path = url.match(/^(https?\:\/\/.*?\/)(.*)/).to_a[1..2] url = "#{host}get/#{path}" else # path url = "/get#{url}" end end else html_options = convert_options_to_data_attributes(options, html_options) url = url_for(options) end href = html_options['href'] tag_options = tag_options(html_options) href_attr = "href=\"#{html_escape(url)}\"" unless href "<a #{href_attr}#{tag_options}>#{html_escape(name || url)}</a>".html_safe end end
Private Instance Methods
post?()
click to toggle source
# File lib/post-em-all.rb, line 107 def post? instance_exec(&PostEmAll::Post.post?) end