Sha256: f5cf6a1d176086f3db0dfe5610e16fc160f53864ef355f4d3a20ba46a6b2a2f4

Contents?: true

Size: 873 Bytes

Versions: 5

Compression:

Stored size: 873 Bytes

Contents

# frozen_string_literal: true

module Decidim
  #
  # Decorator for notifications in mail digest
  #
  class NotificationToMailerPresenter < SimpleDelegator
    include Decidim::TranslatableAttributes

    delegate :url_helpers, to: "Decidim::Core::Engine.routes"
    delegate :resource_title, to: :event
    delegate :resource_url, to: :event
    delegate :email_intro, to: :event
    delegate :resource_path, to: :event

    def date_time
      if frequency == :daily
        created_at.strftime("%H:%M")
      else
        I18n.l(created_at, format: :decidim_short)
      end
    end

    private

    def event
      @event ||= event_class.constantize.new(
        resource: resource,
        user: user,
        event_name: event_name,
        extra: extra
      )
    end

    def frequency
      @frequency ||= user.notifications_sending_frequency
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
decidim-core-0.27.2 app/presenters/decidim/notification_to_mailer_presenter.rb
decidim-core-0.27.1 app/presenters/decidim/notification_to_mailer_presenter.rb
decidim-core-0.27.0 app/presenters/decidim/notification_to_mailer_presenter.rb
decidim-core-0.27.0.rc2 app/presenters/decidim/notification_to_mailer_presenter.rb
decidim-core-0.27.0.rc1 app/presenters/decidim/notification_to_mailer_presenter.rb