Class: RedirectDecorator

Inherits:
ApplicationDecorator show all
Defined in:
app/decorators/redirect_decorator.rb

Instance Method Summary collapse

Methods inherited from ApplicationDecorator

collection_decorator_class

Instance Method Details

#status_badgeObject



4
5
6
# File 'app/decorators/redirect_decorator.rb', line 4

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

#status_code_collectionObject



8
9
10
11
12
# File 'app/decorators/redirect_decorator.rb', line 8

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

#summaryObject



14
15
16
# File 'app/decorators/redirect_decorator.rb', line 14

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

#tooltip_identifierObject



18
19
20
21
22
# File 'app/decorators/redirect_decorator.rb', line 18

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

#tooltip_textObject



24
25
26
# File 'app/decorators/redirect_decorator.rb', line 24

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

#truncated_uri(type, length: 50) ⇒ Object



28
29
30
31
32
33
34
35
# File 'app/decorators/redirect_decorator.rb', line 28

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

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