Class: Decidim::Log::BasePresenter

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/decidim/log/base_presenter.rb

Overview

This class holds the logic to present a resource for any activity log. It is supposed to be a base class for all other log renderers, as it defines some helpful methods that later presenters can use.

Most presenters that inherit from this class will only need to overwrite the ‘action_string` method, which defines what I18n key will be used for each action. Other methods that might be interesting to overwrite are those named `present_*`. Check the source code and the method docs to see how they work.

See ‘Decidim::ActionLog#render_log` for more info on the log types and presenters.

Usage should be automatic and you should not need to call this class directly, but here is an example:

action_log = Decidim::ActionLog.last
view_helpers # => this comes from the views
BasePresenter.new(action_log, view_helpers).present

Instance Method Summary collapse

Constructor Details

#initialize(action_log, view_helpers) ⇒ BasePresenter

Public: Initializes the presenter.

action_log - An instance of Decidim::ActionLog view_helpers - An object holding the view helpers at the render time.

Most probably should come automatically from the views.


30
31
32
33
# File 'app/presenters/decidim/log/base_presenter.rb', line 30

def initialize(action_log, view_helpers)
  @action_log = action_log
  @view_helpers = view_helpers
end

Instance Method Details

#presentObject

Public: Renders the given ‘action_log`.

action_log - An instance of Decidim::ActionLog.last view_helpers - An object holding the view helpers at the render time.

Most probably should come automatically from the views.

Returns an HTML-safe String.



42
43
44
# File 'app/presenters/decidim/log/base_presenter.rb', line 42

def present
  present_action_log
end