Sha256: 25ec9ecebafef647af34aa516492a80ac307c1d5efaeb97a8c761ebfb4de488a

Contents?: true

Size: 951 Bytes

Versions: 4

Compression:

Stored size: 951 Bytes

Contents

require 'action_view'
require 'delegate'

class MenuLinkPresenter < SimpleDelegator
  include ActionView::Helpers::TagHelper

  def featured_tag(name)
    if featured?
      content_tag(:em, name.html_safe)
    else
      name
    end
  end

  def badge
    return "" if no_badge?

    content_tag(:span, link.badge, class: 'badge')
  end

  def certification_badge
   return "" if no_certification_badge?

    content_tag(:span, content_tag(:i, '', class: "cert-status-#{link.certification_badge}") + " #{link.certification_badge.titleize}", class: 'badge label-icon')
  end

  def css_class
    "active" if selected?
  end

  private

  def link
    __getobj__
  end

  def featured?
    link.respond_to?(:featured) && link.featured
  end

  def no_badge?
    !link.respond_to?(:badge)
  end

  def no_certification_badge?
    !link.respond_to?(:certification_badge)
  end

  def selected?
    link.respond_to?(:selected) && link.selected
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
woople-theme-0.0.5 app/presenters/menu_link_presenter.rb
woople-theme-0.0.4 app/presenters/menu_link_presenter.rb
woople-theme-0.0.3 app/presenters/menu_link_presenter.rb
woople-theme-0.0.2 app/presenters/menu_link_presenter.rb