Sha256: 4956f712f672263de3a6e93cccc6133e44fa74ce69c61ca5b4970f669e6c4d6b

Contents?: true

Size: 844 Bytes

Versions: 3

Compression:

Stored size: 844 Bytes

Contents

class RedirectDecorator < ApplicationDecorator
  delegate_all

  def status_badge
    @status_badge ||= Udongo::Redirects::StatusBadge.new(h, object)
  end

  def status_code_collection
    %w(301 303 307).map do |code|
      [I18n.t("b.msg.status_codes.#{code}"), code]
    end
  end

  def summary
    "#{I18n.t('b.from')} #{object.source_uri} #{I18n.t('b.to').downcase} #{object.destination_uri}"
  end

  def tooltip_identifier
    return :untested if working.nil?
    return :working if working?
    :broken
  end

  def tooltip_text
    h.t("b.msg.redirects.tooltips.#{tooltip_identifier}")
  end

  def truncated_uri(type, length: 50)
    value = object.send(type)

    return value if value.length <= length
    h.content_tag :span, data: { toggle: 'tooltip' }, title: value do
      h.truncate(value, length: length)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
udongo-7.9.0 app/decorators/redirect_decorator.rb
udongo-7.8.1 app/decorators/redirect_decorator.rb
udongo-7.8.0 app/decorators/redirect_decorator.rb