Sha256: 496fa2971aafb93906da23865e07e221b27c8d29a93ead3f6a30e36444b7bde5

Contents?: true

Size: 643 Bytes

Versions: 13

Compression:

Stored size: 643 Bytes

Contents

# frozen_string_literal: true

module Decidim
  #
  # Decorator for notifications.
  #
  class NotificationPresenter < SimpleDelegator
    include ActionView::Helpers::DateHelper

    delegate :resource_text, to: :event_class_instance

    def created_at_in_words
      if created_at.between?(1.month.ago, Time.current)
        time_ago_in_words(created_at)
      else
        format = created_at.year == Time.current.year ? :ddmm : :ddmmyyyy
        I18n.l(created_at, format: format)
      end
    end

    def display_resource_text?
      event_class.constantize.included_modules.include?(Decidim::Comments::CommentEvent)
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
decidim-core-0.26.5 app/presenters/decidim/notification_presenter.rb
decidim-core-0.27.2 app/presenters/decidim/notification_presenter.rb
decidim-core-0.27.1 app/presenters/decidim/notification_presenter.rb
decidim-core-0.26.4 app/presenters/decidim/notification_presenter.rb
decidim-core-0.27.0 app/presenters/decidim/notification_presenter.rb
decidim-core-0.26.3 app/presenters/decidim/notification_presenter.rb
decidim-core-0.27.0.rc2 app/presenters/decidim/notification_presenter.rb
decidim-core-0.27.0.rc1 app/presenters/decidim/notification_presenter.rb
decidim-core-0.26.2 app/presenters/decidim/notification_presenter.rb
decidim-core-0.26.1 app/presenters/decidim/notification_presenter.rb
decidim-core-0.26.0 app/presenters/decidim/notification_presenter.rb
decidim-core-0.26.0.rc2 app/presenters/decidim/notification_presenter.rb
decidim-core-0.26.0.rc1 app/presenters/decidim/notification_presenter.rb