Sha256: 8aa1e68d369b0f03a99da20781291a57106bf7dc634c5a8e94326a437c722ef9

Contents?: true

Size: 869 Bytes

Versions: 64

Compression:

Stored size: 869 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Log
    module ValueTypes
      # This class presents the given value as a Decidim::Conference. Check
      # the `DefaultPresenter` for more info on how value
      # presenters work.
      class ConferencePresenter < DefaultPresenter
        # Public: Presents the value as a Decidim::Conference. If the conference
        # can be found, it shows its title. Otherwise it shows its ID.
        #
        # Returns an HTML-safe String.
        def present
          return unless value
          return h.translated_attribute(conference.title) if conference

          I18n.t("not_found", id: value, scope: "decidim.log.value_types.conference_presenter")
        end

        private

        def conference
          @conference ||= Decidim::Conference.find_by(id: value)
        end
      end
    end
  end
end

Version data entries

64 entries across 64 versions & 1 rubygems

Version Path
decidim-conferences-0.20.1 app/presenters/decidim/log/value_types/conference_presenter.rb
decidim-conferences-0.20.0 app/presenters/decidim/log/value_types/conference_presenter.rb
decidim-conferences-0.19.1 app/presenters/decidim/log/value_types/conference_presenter.rb
decidim-conferences-0.19.0 app/presenters/decidim/log/value_types/conference_presenter.rb