Sha256: a448c9e74fcc058858d9c7493d49bfee1e6a7b17fec8544540d14ccd674ba245

Contents?: true

Size: 808 Bytes

Versions: 64

Compression:

Stored size: 808 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Log
    module ValueTypes
      # This class presents the given value as a Decidim::Area. Check
      # the `DefaultPresenter` for more info on how value
      # presenters work.
      class AreaPresenter < DefaultPresenter
        # Public: Presents the value as a Decidim::Area. If the area 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(area.name) if area

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

        private

        def area
          @area ||= Decidim::Area.find_by(id: value)
        end
      end
    end
  end
end

Version data entries

64 entries across 64 versions & 1 rubygems

Version Path
decidim-core-0.25.0.rc4 app/presenters/decidim/log/value_types/area_presenter.rb
decidim-core-0.25.0.rc3 app/presenters/decidim/log/value_types/area_presenter.rb
decidim-core-0.25.0.rc2 app/presenters/decidim/log/value_types/area_presenter.rb
decidim-core-0.25.0.rc1 app/presenters/decidim/log/value_types/area_presenter.rb
decidim-core-0.24.3 app/presenters/decidim/log/value_types/area_presenter.rb
decidim-core-0.23.6 app/presenters/decidim/log/value_types/area_presenter.rb
decidim-core-0.24.2 app/presenters/decidim/log/value_types/area_presenter.rb
decidim-core-0.23.5 app/presenters/decidim/log/value_types/area_presenter.rb
decidim-core-0.24.1 app/presenters/decidim/log/value_types/area_presenter.rb
decidim-core-0.24.0 app/presenters/decidim/log/value_types/area_presenter.rb
decidim-core-0.24.0.rc2 app/presenters/decidim/log/value_types/area_presenter.rb
decidim-core-0.23.4 app/presenters/decidim/log/value_types/area_presenter.rb
decidim-core-0.24.0.rc1 app/presenters/decidim/log/value_types/area_presenter.rb
decidim-core-0.23.3 app/presenters/decidim/log/value_types/area_presenter.rb
decidim-core-0.23.2 app/presenters/decidim/log/value_types/area_presenter.rb
decidim-core-0.23.1 app/presenters/decidim/log/value_types/area_presenter.rb
decidim-core-0.23.1.rc1 app/presenters/decidim/log/value_types/area_presenter.rb
decidim-core-0.23.0 app/presenters/decidim/log/value_types/area_presenter.rb
decidim-core-0.22.0 app/presenters/decidim/log/value_types/area_presenter.rb
decidim-core-0.21.0 app/presenters/decidim/log/value_types/area_presenter.rb