Class: Viewable::LinkListPresenter

Inherits:
ViewableListPresenter show all
Defined in:
app/presenters/viewable/link_list_presenter.rb

Instance Attribute Summary

Attributes inherited from BaseListPresenter

#context, #list

Instance Method Summary collapse

Methods inherited from ViewableListPresenter

#add_link, #edit_links, #initialize, #sortable, #sortable_html, #ul_sortable_tag

Methods inherited from BaseListPresenter

#initialize

Constructor Details

This class inherits a constructor from ViewableListPresenter

Instance Method Details


23
24
25
26
27
28
# File 'app/presenters/viewable/link_list_presenter.rb', line 23

def active_link
  @active_link ||= begin
    breadcrumbs
    @active_link
  end
end

#active_menu?Boolean

Returns:

  • (Boolean)

19
20
21
# File 'app/presenters/viewable/link_list_presenter.rb', line 19

def active_menu?
  !!active_link
end

30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/presenters/viewable/link_list_presenter.rb', line 30

def breadcrumbs
  @breadcrumbs ||= begin
    @active_link = nil
    take_while do |link|
      if link.active?
        @active_link = link
        false
      else
        true
      end
    end
  end
end

12
13
14
15
16
17
# File 'app/presenters/viewable/link_list_presenter.rb', line 12

def menu
  each do |link|
    h.concat link.li_link_to_with_edit
  end
  h.concat(add_link) if h.cms_edit_mode?
end

#wrapped_menu(name) ⇒ Object


3
4
5
6
7
8
9
10
# File 'app/presenters/viewable/link_list_presenter.rb', line 3

def wrapped_menu(name)
  h. :li do
    h.concat h.active_link_to(name, '#', active: active_menu?)
    h.concat(h.(:ul, sortable) do
      menu
    end)
  end
end