Sha256: 205bc3fd765f917c395c84955c12aa4fc83a3fc3d0152d2330e7e9672e15d793

Contents?: true

Size: 851 Bytes

Versions: 64

Compression:

Stored size: 851 Bytes

Contents

# frozen_string_literal: true

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

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

        private

        def scope_type
          @scope_type ||= Decidim::ScopeType.find_by(id: value)
        end
      end
    end
  end
end

Version data entries

64 entries across 64 versions & 1 rubygems

Version Path
decidim-core-0.29.1 app/presenters/decidim/log/value_types/scope_type_presenter.rb
decidim-core-0.28.4 app/presenters/decidim/log/value_types/scope_type_presenter.rb
decidim-core-0.27.9 app/presenters/decidim/log/value_types/scope_type_presenter.rb
decidim-core-0.29.0 app/presenters/decidim/log/value_types/scope_type_presenter.rb
decidim-core-0.28.3 app/presenters/decidim/log/value_types/scope_type_presenter.rb
decidim-core-0.27.8 app/presenters/decidim/log/value_types/scope_type_presenter.rb
decidim-core-0.29.0.rc4 app/presenters/decidim/log/value_types/scope_type_presenter.rb
decidim-core-0.29.0.rc3 app/presenters/decidim/log/value_types/scope_type_presenter.rb
decidim-core-0.29.0.rc2 app/presenters/decidim/log/value_types/scope_type_presenter.rb
decidim-core-0.29.0.rc1 app/presenters/decidim/log/value_types/scope_type_presenter.rb
decidim-core-0.28.2 app/presenters/decidim/log/value_types/scope_type_presenter.rb
decidim-core-0.27.7 app/presenters/decidim/log/value_types/scope_type_presenter.rb
decidim-core-0.28.1 app/presenters/decidim/log/value_types/scope_type_presenter.rb
decidim-core-0.27.6 app/presenters/decidim/log/value_types/scope_type_presenter.rb
decidim-core-0.26.10 app/presenters/decidim/log/value_types/scope_type_presenter.rb
decidim-core-0.26.9 app/presenters/decidim/log/value_types/scope_type_presenter.rb
decidim-core-0.28.0 app/presenters/decidim/log/value_types/scope_type_presenter.rb
decidim-core-0.27.5 app/presenters/decidim/log/value_types/scope_type_presenter.rb
decidim-core-0.28.0.rc5 app/presenters/decidim/log/value_types/scope_type_presenter.rb
decidim-core-0.28.0.rc4 app/presenters/decidim/log/value_types/scope_type_presenter.rb