Sha256: 5120dbc236daa82b58c4244531ceebbb32bdfebaa41b567515cec26f8bcd708b

Contents?: true

Size: 1.47 KB

Versions: 32

Compression:

Stored size: 1.47 KB

Contents

# frozen_string_literal: true

module Decidim
  module Log
    module ValueTypes
      # 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.
      class DefaultPresenter
        # value - the vakue 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.
        def initialize(value, view_helpers)
          @value = value
          @view_helpers = view_helpers
        end

        # 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.
        def present
          value
        end

        private

        attr_reader :value, :view_helpers
        alias h view_helpers
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
decidim-core-0.22.0 app/presenters/decidim/log/value_types/default_presenter.rb
decidim-core-0.21.0 app/presenters/decidim/log/value_types/default_presenter.rb
decidim-core-0.20.1 app/presenters/decidim/log/value_types/default_presenter.rb
decidim-core-0.20.0 app/presenters/decidim/log/value_types/default_presenter.rb
decidim-core-0.19.1 app/presenters/decidim/log/value_types/default_presenter.rb
decidim-core-0.18.1 app/presenters/decidim/log/value_types/default_presenter.rb
decidim-core-0.19.0 app/presenters/decidim/log/value_types/default_presenter.rb
decidim-core-0.17.2 app/presenters/decidim/log/value_types/default_presenter.rb
decidim-core-0.18.0 app/presenters/decidim/log/value_types/default_presenter.rb
decidim-core-0.17.1 app/presenters/decidim/log/value_types/default_presenter.rb
decidim-core-0.16.1 app/presenters/decidim/log/value_types/default_presenter.rb
decidim-core-0.17.0 app/presenters/decidim/log/value_types/default_presenter.rb
decidim-core-0.16.0 app/presenters/decidim/log/value_types/default_presenter.rb
decidim-core-0.15.2 app/presenters/decidim/log/value_types/default_presenter.rb
decidim-core-0.15.1 app/presenters/decidim/log/value_types/default_presenter.rb
decidim-core-0.15.0 app/presenters/decidim/log/value_types/default_presenter.rb
decidim-core-0.14.4 app/presenters/decidim/log/value_types/default_presenter.rb
decidim-core-0.14.3 app/presenters/decidim/log/value_types/default_presenter.rb
decidim-core-0.14.2 app/presenters/decidim/log/value_types/default_presenter.rb
decidim-core-0.14.1 app/presenters/decidim/log/value_types/default_presenter.rb