Sha256: 659491276e32418f708b2f44ecf5ba2d3715f44c5309270705a80b8d55e94cde

Contents?: true

Size: 848 Bytes

Versions: 24

Compression:

Stored size: 848 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Log
    module ValueTypes
      # This class presents the given value as a Decidim::Assembly. Check
      # the `DefaultPresenter` for more info on how value
      # presenters work.
      class AssemblyPresenter < DefaultPresenter
        # Public: Presents the value as a Decidim::Assembly. If the assembly
        # 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(assembly.title) if assembly
          I18n.t("not_found", id: value, scope: "decidim.log.value_types.assembly_presenter")
        end

        private

        def assembly
          @assembly ||= Decidim::Assembly.find_by(id: value)
        end
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
decidim-assemblies-0.18.1 app/presenters/decidim/log/value_types/assembly_presenter.rb
decidim-assemblies-0.17.2 app/presenters/decidim/log/value_types/assembly_presenter.rb
decidim-assemblies-0.18.0 app/presenters/decidim/log/value_types/assembly_presenter.rb
decidim-assemblies-0.17.1 app/presenters/decidim/log/value_types/assembly_presenter.rb
decidim-assemblies-0.16.1 app/presenters/decidim/log/value_types/assembly_presenter.rb
decidim-assemblies-0.17.0 app/presenters/decidim/log/value_types/assembly_presenter.rb
decidim-assemblies-0.16.0 app/presenters/decidim/log/value_types/assembly_presenter.rb
decidim-assemblies-0.15.2 app/presenters/decidim/log/value_types/assembly_presenter.rb
decidim-assemblies-0.15.1 app/presenters/decidim/log/value_types/assembly_presenter.rb
decidim-assemblies-0.15.0 app/presenters/decidim/log/value_types/assembly_presenter.rb
decidim-assemblies-0.14.4 app/presenters/decidim/log/value_types/assembly_presenter.rb
decidim-assemblies-0.14.3 app/presenters/decidim/log/value_types/assembly_presenter.rb
decidim-assemblies-0.14.2 app/presenters/decidim/log/value_types/assembly_presenter.rb
decidim-assemblies-0.14.1 app/presenters/decidim/log/value_types/assembly_presenter.rb
decidim-assemblies-0.13.1 app/presenters/decidim/log/value_types/assembly_presenter.rb
decidim-assemblies-0.12.2 app/presenters/decidim/log/value_types/assembly_presenter.rb
decidim-assemblies-0.13.0 app/presenters/decidim/log/value_types/assembly_presenter.rb
decidim-assemblies-0.12.1 app/presenters/decidim/log/value_types/assembly_presenter.rb
decidim-assemblies-0.13.0.pre1 app/presenters/decidim/log/value_types/assembly_presenter.rb
decidim-assemblies-0.12.0 app/presenters/decidim/log/value_types/assembly_presenter.rb