Class: Abc::Html::MenuPresenter
- Inherits:
-
Object
- Object
- Abc::Html::MenuPresenter
- Includes:
- ActionView::Context, ActionView::Helpers::TagHelper
- Defined in:
- app/presenters/abc/html/menu_presenter.rb
Instance Attribute Summary collapse
-
#list_element_pair ⇒ Object
Returns the value of attribute list_element_pair.
-
#menu ⇒ Object
Returns the value of attribute menu.
-
#menu_element ⇒ Object
Returns the value of attribute menu_element.
-
#menu_entry_presenter_class ⇒ Object
Returns the value of attribute menu_entry_presenter_class.
Instance Method Summary collapse
-
#initialize(menu, options = {}) ⇒ MenuPresenter
constructor
A new instance of MenuPresenter.
-
#to_html ⇒ Object
Outputs the menu in HTML format.
Constructor Details
#initialize(menu, options = {}) ⇒ MenuPresenter
Returns a new instance of MenuPresenter.
12 13 14 15 16 17 18 19 |
# File 'app/presenters/abc/html/menu_presenter.rb', line 12 def initialize(, = {}) = .merge() self. = self. = [:menu_element] self.list_element_pair = [:list_element_pair] self. = [:menu_entry_presenter_class] end |
Instance Attribute Details
#list_element_pair ⇒ Object
Returns the value of attribute list_element_pair.
10 11 12 |
# File 'app/presenters/abc/html/menu_presenter.rb', line 10 def list_element_pair @list_element_pair end |
#menu ⇒ Object
Returns the value of attribute menu.
10 11 12 |
# File 'app/presenters/abc/html/menu_presenter.rb', line 10 def @menu end |
#menu_element ⇒ Object
Returns the value of attribute menu_element.
10 11 12 |
# File 'app/presenters/abc/html/menu_presenter.rb', line 10 def @menu_element end |
#menu_entry_presenter_class ⇒ Object
Returns the value of attribute menu_entry_presenter_class.
10 11 12 |
# File 'app/presenters/abc/html/menu_presenter.rb', line 10 def @menu_entry_presenter_class end |
Instance Method Details
#to_html ⇒ Object
Outputs the menu in HTML format.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/presenters/abc/html/menu_presenter.rb', line 24 def to_html content_tag() do content_tag(list_container_tag) do # Reduce will concat into a first SafeBuffer here, so if the first # node is html_safe, this will produce expected outcome. And of course, # MenuEntries are expected to be html_safe. .reduce(::ActiveSupport::SafeBuffer.new) do |buffer, child| = .new( child, :list_element_pair => list_element_pair ) buffer.safe_concat .to_html end end end.html_safe end |