module BMC::LinkHelper def link_to_object(obj, options = {}) return if obj.nil? if policy(obj).read? link_to(obj.to_s, engine_polymorphic_path(obj), options) else obj.to_s end end def icon_link_to(icon, name, options = nil, html_options = nil, &block) name = icon(icon).concat(" ").concat(name) link_to(name, options, html_options, &block) end 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 def email_link(text, opts = {}) return if text.to_s.blank? href = "mailto:#{text}" link_to(text, href, opts) end def tel_link(text, opts = {}) return if text.to_s.blank? value = text.delete(" ") href = "tel:#{value}" link_to(text, href, opts) end end