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’ll 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, 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
# File 'app/presenters/decidim/log/diff_presenter.rb', line 19

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

Instance Method Details

#presentObject

Public: Renders the given diff.

Returns an HTML-safe String.



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

def present
  present_diff
end