Class: Decidim::Log::ResourcePresenter

Inherits:
Object
  • Object
show all
Defined in:
decidim-core/app/presenters/decidim/log/resource_presenter.rb

Overview

This class holds the logic to present the resource 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 resource, you will need to overwrite ‘BasePresenter#resource_presenter` to return your custom resource presenter. The only requirement for custom renderers is that they should respond to `present`.

Instance Method Summary collapse

Constructor Details

#initialize(resource, view_helpers, extra) ⇒ ResourcePresenter

Public: Initializes the presenter.

resource - An instance of a model that can be located by

`Decidim::ResourceLocatorPresenter`

view_helpers - An object holding the view helpers at the render time.

Most probably should come automatically from the views.

extra - a Hash with extra data, most likely coming from the

`action_log` being presented


21
22
23
24
25
# File 'decidim-core/app/presenters/decidim/log/resource_presenter.rb', line 21

def initialize(resource, view_helpers, extra)
  @resource = resource
  @view_helpers = view_helpers
  @extra = extra
end

Instance Method Details

#presentObject

Public: Renders the given resource.

Returns an HTML-safe String.



30
31
32
# File 'decidim-core/app/presenters/decidim/log/resource_presenter.rb', line 30

def present
  present_resource
end