Class: Decidim::Log::ValueTypes::DefaultPresenter
- Inherits:
-
Object
- Object
- Decidim::Log::ValueTypes::DefaultPresenter
- Defined in:
- app/presenters/decidim/log/value_types/default_presenter.rb
Overview
This class is used as a base for other value presenters, and as a default presenter when the presenter for the given value is not specified or is not found.
Value presenters are dynamically found from the value type set in the ‘fields_mapping` method in the resource presenter. If the value is a symbol, the system will try to infer the correct presenter and use it. If it’s a String, it will treat it as a class name, and will try to fetch that presenter. If the system fails in either case, it will use the ‘DefaultPresenter`.
Check the other presenters in this folder for more examples.
Direct Known Subclasses
AreaPresenter, AreaTypePresenter, CurrencyPresenter, DatePresenter, LocalePresenter, PercentagePresenter, ScopePresenter, ScopeTypePresenter
Instance Method Summary collapse
-
#initialize(value, view_helpers) ⇒ DefaultPresenter
constructor
value - the value to render, can be of any type.
-
#present ⇒ Object
Public: Presents the value in a specific format.
Constructor Details
#initialize(value, view_helpers) ⇒ DefaultPresenter
value - the value to render, can be of any type. view_helpers - an object encapsulating all the view helpers,
it will most likely come from the top of the chain.
22 23 24 25 |
# File 'app/presenters/decidim/log/value_types/default_presenter.rb', line 22 def initialize(value, view_helpers) @value = value @view_helpers = view_helpers end |
Instance Method Details
#present ⇒ Object
Public: Presents the value in a specific format. In this method you can use any view helper you need, but it’s important to return an HTML-safe String.
Returns an HTML-safe String.
32 33 34 |
# File 'app/presenters/decidim/log/value_types/default_presenter.rb', line 32 def present value end |