Sha256: 4062a0735927ecf09994a1ab0d04ef9f42468ba7ab90c7f317be469a87b78227

Contents?: true

Size: 858 Bytes

Versions: 5

Compression:

Stored size: 858 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, &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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
bmc-1.2.1 app/helpers/bmc/link_helper.rb
bmc-1.2.0 app/helpers/bmc/link_helper.rb
bmc-1.1.0 app/helpers/bmc/link_helper.rb
bmc-1.0.1 app/helpers/bmc/link_helper.rb
bmc-1.0.0 app/helpers/bmc/link_helper.rb