Sha256: 8e7b55cda9412875c83eae69fafdbc5337ed96ab872cb5fc325691b427a265b4

Contents?: true

Size: 470 Bytes

Versions: 10

Compression:

Stored size: 470 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 && 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

10 entries across 10 versions & 1 rubygems

Version Path
thredded-0.12.1 app/models/concerns/thredded/notifier_preference.rb
thredded-0.12.0 app/models/concerns/thredded/notifier_preference.rb
thredded-0.11.1 app/models/concerns/thredded/notifier_preference.rb
thredded-0.11.0 app/models/concerns/thredded/notifier_preference.rb
thredded-0.10.1 app/models/concerns/thredded/notifier_preference.rb
thredded-0.10.0 app/models/concerns/thredded/notifier_preference.rb
thredded-0.9.4 app/models/concerns/thredded/notifier_preference.rb
thredded-0.9.3 app/models/concerns/thredded/notifier_preference.rb
thredded-0.9.2 app/models/concerns/thredded/notifier_preference.rb
thredded-0.9.1 app/models/concerns/thredded/notifier_preference.rb