Class: Georgia::SidebarLinkPresenter

Inherits:
Presenter
  • Object
show all
Defined in:
app/presenters/georgia/sidebar_link_presenter.rb

Instance Attribute Summary collapse

Attributes inherited from Presenter

#view_context

Instance Method Summary collapse

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, options={}
  @view_context = view_context
  @text = text
  @url = url
  @options = options
  @icon = options.fetch(:icon, 'bookmark-o')
  @active = options.fetch(:active) { get_active_state_from_controller }
  @sublink = options.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

#activeObject (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

#iconObject (readonly)

Returns the value of attribute icon.



4
5
6
# File 'app/presenters/georgia/sidebar_link_presenter.rb', line 4

def icon
  @icon
end

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'app/presenters/georgia/sidebar_link_presenter.rb', line 4

def options
  @options
end

Returns the value of attribute sublink.



4
5
6
# File 'app/presenters/georgia/sidebar_link_presenter.rb', line 4

def sublink
  @sublink
end

#textObject (readonly)

Returns the value of attribute text.



4
5
6
# File 'app/presenters/georgia/sidebar_link_presenter.rb', line 4

def text
  @text
end

#urlObject (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



23
24
25
# File 'app/presenters/georgia/sidebar_link_presenter.rb', line 23

def render_link
   :li, link_to(sidebar_link_bundle, url), class: "#{'active' if active?}"
end


27
28
29
# File 'app/presenters/georgia/sidebar_link_presenter.rb', line 27

def render_sublink
   :li, link_to(sidebar_title_tag, url), class: "#{'active' if active?}"
end

#to_sObject



19
20
21
# File 'app/presenters/georgia/sidebar_link_presenter.rb', line 19

def to_s
  !sublink? ? render_link : render_sublink
end