Sha256: db0fd9446f2deb70245f4ddf41eeaa9e65e06c96acedbcef4a7e768b78c6cae6

Contents?: true

Size: 961 Bytes

Versions: 41

Compression:

Stored size: 961 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.html_safe
    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

41 entries across 41 versions & 1 rubygems

Version Path
woople-theme-0.0.6 app/presenters/menu_link_presenter.rb