discourse/plugins/automation/lib/discourse_automation/engine.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

22 lines
532 B
Ruby
Raw Normal View History

# frozen_string_literal: true
module ::DiscourseAutomation
class Engine < ::Rails::Engine
engine_name PLUGIN_NAME
isolate_namespace DiscourseAutomation
end
def self.filter_by_trigger(items, trigger)
trigger = trigger&.to_sym
indexed_items =
items.each_with_object({}) do |item, acc|
if item[:triggerable] == trigger || item[:triggerable].nil?
acc[item[:name]] = item if acc[item[:name]].nil? || item[:triggerable] == trigger
end
end
indexed_items.values
end
end