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.25.0.rc4 app/presenters/decidim/log/value_types/conference_presenter.rb
decidim-conferences-0.25.0.rc3 app/presenters/decidim/log/value_types/conference_presenter.rb
decidim-conferences-0.25.0.rc2 app/presenters/decidim/log/value_types/conference_presenter.rb
decidim-conferences-0.25.0.rc1 app/presenters/decidim/log/value_types/conference_presenter.rb
decidim-conferences-0.24.3 app/presenters/decidim/log/value_types/conference_presenter.rb
decidim-conferences-0.23.6 app/presenters/decidim/log/value_types/conference_presenter.rb
decidim-conferences-0.24.2 app/presenters/decidim/log/value_types/conference_presenter.rb
decidim-conferences-0.23.5 app/presenters/decidim/log/value_types/conference_presenter.rb
decidim-conferences-0.24.1 app/presenters/decidim/log/value_types/conference_presenter.rb
decidim-conferences-0.24.0 app/presenters/decidim/log/value_types/conference_presenter.rb
decidim-conferences-0.24.0.rc2 app/presenters/decidim/log/value_types/conference_presenter.rb
decidim-conferences-0.23.4 app/presenters/decidim/log/value_types/conference_presenter.rb
decidim-conferences-0.24.0.rc1 app/presenters/decidim/log/value_types/conference_presenter.rb
decidim-conferences-0.23.3 app/presenters/decidim/log/value_types/conference_presenter.rb
decidim-conferences-0.23.2 app/presenters/decidim/log/value_types/conference_presenter.rb
decidim-conferences-0.23.1 app/presenters/decidim/log/value_types/conference_presenter.rb
decidim-conferences-0.23.1.rc1 app/presenters/decidim/log/value_types/conference_presenter.rb
decidim-conferences-0.23.0 app/presenters/decidim/log/value_types/conference_presenter.rb
decidim-conferences-0.22.0 app/presenters/decidim/log/value_types/conference_presenter.rb
decidim-conferences-0.21.0 app/presenters/decidim/log/value_types/conference_presenter.rb