Module: ActionView::Helpers::UrlHelper
- Defined in:
- lib/obscura_linka.rb
Instance Method Summary collapse
-
#obscura_link_to(name = nil, options = nil, html_options = nil, &block) ⇒ Object
Call obscura_link_to like a regular link_to example: obuscra_link_to(“My link”, root_path).
Instance Method Details
#obscura_link_to(name = nil, options = nil, html_options = nil, &block) ⇒ Object
Call obscura_link_to like a regular link_to example: obuscra_link_to(“My link”, root_path)
Output is <a herf=“” data-href=“obfuscated_link” class=‘obfuscated_link’>My link</a>
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/obscura_linka.rb', line 13 def obscura_link_to(name = nil, = nil, = nil, &block) , , name = , name, block if block_given? url = ||= {} # obfuscate the url = url.tr("A-Za-z", "N-ZA-Mn-za-m") [:data] ||= {} [:data][:href] = [:class] ||= "" [:class] << " rot13_link" # put that obfuscated_url into a data attribute if block_given? link_to("", , nil, &block) else link_to(name, "", ) end end |