Class: Decidim::Log::ResourcePresenter
- Inherits:
-
Object
- Object
- Decidim::Log::ResourcePresenter
- Includes:
- SanitizeHelper
- Defined in:
- 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`.
Direct Known Subclasses
AdminLog::NewsletterResourcePresenter, AdminLog::OAuthApplicationResourcePresenter, AdminLog::StaticPageResourcePresenter
Instance Method Summary collapse
-
#initialize(resource, view_helpers, extra) ⇒ ResourcePresenter
constructor
Public: Initializes the presenter.
-
#present ⇒ Object
Public: Renders the given resource.
Methods included from SanitizeHelper
#decidim_escape_translated, #decidim_html_escape, #decidim_sanitize, #decidim_sanitize_admin, #decidim_sanitize_editor, #decidim_sanitize_editor_admin, #decidim_sanitize_newsletter, #decidim_sanitize_translated, #decidim_url_escape, included
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
23 24 25 26 27 |
# File 'app/presenters/decidim/log/resource_presenter.rb', line 23 def initialize(resource, view_helpers, extra) @resource = resource @view_helpers = view_helpers @extra = extra end |
Instance Method Details
#present ⇒ Object
Public: Renders the given resource.
Returns an HTML-safe String.
32 33 34 |
# File 'app/presenters/decidim/log/resource_presenter.rb', line 32 def present present_resource end |