Sha256: 0d14318778415119aaa8a546d30be3333bdb0465bb3211755ce51861c928065c

Contents?: true

Size: 961 Bytes

Versions: 90

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

90 entries across 90 versions & 1 rubygems

Version Path
woople-theme-0.10.0 app/presenters/menu_link_presenter.rb
woople-theme-0.9.0 app/presenters/menu_link_presenter.rb
woople-theme-0.8.19 app/presenters/menu_link_presenter.rb
woople-theme-0.8.18 app/presenters/menu_link_presenter.rb
woople-theme-0.8.17 app/presenters/menu_link_presenter.rb
woople-theme-0.8.16 app/presenters/menu_link_presenter.rb
woople-theme-0.8.15 app/presenters/menu_link_presenter.rb
woople-theme-0.8.14 app/presenters/menu_link_presenter.rb
woople-theme-0.8.13 app/presenters/menu_link_presenter.rb
woople-theme-0.8.12 app/presenters/menu_link_presenter.rb
woople-theme-0.8.11 app/presenters/menu_link_presenter.rb
woople-theme-0.8.10 app/presenters/menu_link_presenter.rb
woople-theme-0.8.9 app/presenters/menu_link_presenter.rb
woople-theme-0.8.8 app/presenters/menu_link_presenter.rb
woople-theme-0.8.7 app/presenters/menu_link_presenter.rb
woople-theme-0.8.6 app/presenters/menu_link_presenter.rb
woople-theme-0.8.5 app/presenters/menu_link_presenter.rb
woople-theme-0.8.4 app/presenters/menu_link_presenter.rb
woople-theme-0.8.3 app/presenters/menu_link_presenter.rb
woople-theme-0.8.2 app/presenters/menu_link_presenter.rb