Class: Georgia::SidebarLinkPresenter
- Defined in:
- app/presenters/georgia/sidebar_link_presenter.rb
Instance Attribute Summary collapse
-
#active ⇒ Object
(also: #active?)
readonly
Returns the value of attribute active.
-
#icon ⇒ Object
readonly
Returns the value of attribute icon.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#sublink ⇒ Object
(also: #sublink?)
readonly
Returns the value of attribute sublink.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Attributes inherited from Presenter
Instance Method Summary collapse
-
#initialize(view_context, text, url, options = {}) ⇒ SidebarLinkPresenter
constructor
A new instance of SidebarLinkPresenter.
- #render_link ⇒ Object
- #render_sublink ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(view_context, text, url, options = {}) ⇒ SidebarLinkPresenter
Returns a new instance of SidebarLinkPresenter.
8 9 10 11 12 13 14 15 16 17 |
# File 'app/presenters/georgia/sidebar_link_presenter.rb', line 8 def initialize view_context, text, url, ={} @view_context = view_context @text = text @url = url @options = @icon = .fetch(:icon, 'bookmark-o') @active = .fetch(:active) { get_active_state_from_controller } @sublink = .fetch(:sublink, false) super end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Georgia::Presenter
Instance Attribute Details
#active ⇒ Object (readonly) Also known as: active?
Returns the value of attribute active.
4 5 6 |
# File 'app/presenters/georgia/sidebar_link_presenter.rb', line 4 def active @active end |
#icon ⇒ Object (readonly)
Returns the value of attribute icon.
4 5 6 |
# File 'app/presenters/georgia/sidebar_link_presenter.rb', line 4 def icon @icon end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'app/presenters/georgia/sidebar_link_presenter.rb', line 4 def @options end |
#sublink ⇒ Object (readonly) Also known as: sublink?
Returns the value of attribute sublink.
4 5 6 |
# File 'app/presenters/georgia/sidebar_link_presenter.rb', line 4 def sublink @sublink end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
4 5 6 |
# File 'app/presenters/georgia/sidebar_link_presenter.rb', line 4 def text @text end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
4 5 6 |
# File 'app/presenters/georgia/sidebar_link_presenter.rb', line 4 def url @url end |
Instance Method Details
#render_link ⇒ Object
23 24 25 |
# File 'app/presenters/georgia/sidebar_link_presenter.rb', line 23 def render_link content_tag :li, link_to(, url), class: "#{'active' if active?}" end |
#render_sublink ⇒ Object
27 28 29 |
# File 'app/presenters/georgia/sidebar_link_presenter.rb', line 27 def render_sublink content_tag :li, link_to(, url), class: "#{'active' if active?}" end |
#to_s ⇒ Object
19 20 21 |
# File 'app/presenters/georgia/sidebar_link_presenter.rb', line 19 def to_s !sublink? ? render_link : render_sublink end |