Class: Decidim::Log::DiffPresenter

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

Overview

This class holds the logic to present the diff for any activity log. The data needed for this class to work should be sent by ‘Decidim::Log::BasePresenter` or any of its children.

In order to be able to use your own class to present a diff, you will need to overwrite ‘BasePresenter#diff_presenter` to return your custom diff presenter. The only requirement for custom renderers is that they should respond to `present`.

Instance Method Summary collapse

Constructor Details

#initialize(changeset, view_helpers, action_log, options = {}) ⇒ DiffPresenter

Public: Initializes the presenter.

changeset - An array of hashes view_helpers - An object holding the view helpers at the render time.

Most probably should come automatically from the views.

options - a Hash with options



19
20
21
22
23
24
# File 'app/presenters/decidim/log/diff_presenter.rb', line 19

def initialize(changeset, view_helpers, action_log, options = {})
  @changeset = changeset
  @view_helpers = view_helpers
  @action_log = action_log
  @options = { show_previous_value?: true }.merge(options)
end

Instance Method Details

#presentObject

Public: Renders the given diff.

Returns an HTML-safe String.



29
30
31
# File 'app/presenters/decidim/log/diff_presenter.rb', line 29

def present
  present_diff
end