Sha256: e2fdb8f6096d593b8150db76ea6ea2252ab84b6e7b0115171a600d15c65a5913

Contents?: true

Size: 848 Bytes

Versions: 2

Compression:

Stored size: 848 Bytes

Contents

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, &)
    name = fa_s(icon).concat(" ").concat(name)
    link_to(name, options, html_options, &)
  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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bmc-1.6.1 app/helpers/bmc/link_helper.rb
bmc-1.6.0 app/helpers/bmc/link_helper.rb