Class: Georgia::PageActionsPresenter

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

Instance Attribute Summary collapse

Attributes inherited from Presenter

#view_context

Instance Method Summary collapse

Constructor Details

#initialize(view, page, revision, options = {}) ⇒ PageActionsPresenter

Returns a new instance of PageActionsPresenter.



6
7
8
9
10
11
# File 'app/presenters/georgia/page_actions_presenter.rb', line 6

def initialize view, page, revision, options={}
  @page = (page.decorated? ? page.object : page)
  @revision = (revision.decorated? ? revision.object : revision)
  @options = options
  super
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Georgia::Presenter

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



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

def options
  @options
end

#pageObject

Returns the value of attribute page.



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

def page
  @page
end

#revisionObject

Returns the value of attribute revision.



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

def revision
  @revision
end

Instance Method Details

#action_listObject



20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/presenters/georgia/page_actions_presenter.rb', line 20

def action_list
  html = ActiveSupport::SafeBuffer.new
  html << (:li, link_to_edit) if can?(:edit, page)
  # html << content_tag(:li, link_to_settings) if can?(:settings, page)
  html << (:li, link_to_preview) if can?(:preview, page)
  html << (:li, link_to_copy) if can?(:copy, page)
  html << (:li, link_to_publish) if can?(:publish, page) and !page.published?
  html << (:li, link_to_unpublish) if can?(:unpublish, page) and page.published?
  html << (:li, link_to_flush_cache) if can?(:flush_cache, page)
  html << (:li, link_to_revisions) if can?(:index, Revision)
  html
end

#to_sObject



13
14
15
16
17
18
# File 'app/presenters/georgia/page_actions_presenter.rb', line 13

def to_s
   :div, class: 'dropdown' do
    link_to("Actions #{caret_tag}".html_safe, '#', role: :button, class: 'btn btn-warning', data: {toggle: 'dropdown'}) +
    (:ul, action_list, class: 'dropdown-menu', role: :menu)
  end
end