Sha256: 4729f82096fdcb56ccf676ff3d0653779caf3b2336722776db5b681daf11d331

Contents?: true

Size: 463 Bytes

Versions: 2

Compression:

Stored size: 463 Bytes

Contents

# frozen_string_literal: true

module Thredded
  module NotifierPreference
    extend ActiveSupport::Concern

    included do
      delegate :human_name, to: :notifier, prefix: true

      def self.detect_or_default(prefs, notifier)
        (prefs&.find { |pref| pref.notifier_key == notifier.key }) || default(notifier)
      end
    end

    def notifier
      @notifier ||= Thredded.notifiers.find { |notifier| notifier.key == notifier_key }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
thredded-1.1.0 app/models/concerns/thredded/notifier_preference.rb
thredded-1.0.1 app/models/concerns/thredded/notifier_preference.rb