Module: BMC::LinkHelper
- Included in:
- AllHelpers
- Defined in:
- app/helpers/bmc/link_helper.rb
Instance Method Summary collapse
- #email_link(text, opts = {}) ⇒ Object
- #icon_link_to(icon, name, options = nil, html_options = nil) ⇒ Object
- #link_to_object(obj, options = {}) ⇒ Object
- #tel_link(text, opts = {}) ⇒ Object
- #web_link(text, opts = {}) ⇒ Object
Instance Method Details
#email_link(text, opts = {}) ⇒ Object
26 27 28 29 30 31 32 |
# File 'app/helpers/bmc/link_helper.rb', line 26 def email_link(text, opts = {}) return if text.to_s.blank? href = "mailto:#{text}" link_to(text, href, opts) end |
#icon_link_to(icon, name, options = nil, html_options = nil) ⇒ Object
12 13 14 15 |
# File 'app/helpers/bmc/link_helper.rb', line 12 def icon_link_to(icon, name, = nil, = nil, &) name = fa_s(icon).concat(" ").concat(name) link_to(name, , , &) end |
#link_to_object(obj, options = {}) ⇒ Object
2 3 4 5 6 7 8 9 10 |
# File 'app/helpers/bmc/link_helper.rb', line 2 def link_to_object(obj, = {}) return if obj.nil? if policy(obj).read? link_to(obj.to_s, engine_polymorphic_path(obj), ) else obj.to_s end end |
#tel_link(text, opts = {}) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'app/helpers/bmc/link_helper.rb', line 34 def tel_link(text, opts = {}) return if text.to_s.blank? value = text.delete(" ") href = "tel:#{value}" link_to(text, href, opts) end |
#web_link(text, opts = {}) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'app/helpers/bmc/link_helper.rb', line 17 def web_link(text, opts = {}) return if text.to_s.blank? href = text href = "http://#{text}" unless text.include?("://") link_to(text, href, opts) end |