Sha256: 6c714eebb65510970ee50509b94da0a28003246f15f654f2c70036326587dfd6

Contents?: true

Size: 858 Bytes

Versions: 12

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 = fa_s(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

12 entries across 12 versions & 1 rubygems

Version Path
bmc-1.5.1 app/helpers/bmc/link_helper.rb
bmc-1.5.0 app/helpers/bmc/link_helper.rb
bmc-1.4.3 app/helpers/bmc/link_helper.rb
bmc-1.4.2 app/helpers/bmc/link_helper.rb
bmc-1.4.1 app/helpers/bmc/link_helper.rb
bmc-1.4.0 app/helpers/bmc/link_helper.rb
bmc-1.3.5 app/helpers/bmc/link_helper.rb
bmc-1.3.4 app/helpers/bmc/link_helper.rb
bmc-1.3.3 app/helpers/bmc/link_helper.rb
bmc-1.3.2 app/helpers/bmc/link_helper.rb
bmc-1.3.1 app/helpers/bmc/link_helper.rb
bmc-1.3.0 app/helpers/bmc/link_helper.rb