2019-05-02 17:17:27 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-10-17 12:31:45 -05:00
|
|
|
class FlagSettings
|
|
|
|
attr_reader(
|
2024-07-17 19:10:22 -05:00
|
|
|
:without_additional_message_types,
|
2017-10-17 12:31:45 -05:00
|
|
|
:notify_types,
|
|
|
|
:topic_flag_types,
|
|
|
|
:auto_action_types,
|
2024-07-17 19:10:22 -05:00
|
|
|
:additional_message_types,
|
2024-05-22 21:19:07 -05:00
|
|
|
:names,
|
2017-10-17 12:31:45 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
def initialize
|
|
|
|
@all_flag_types = Enum.new
|
|
|
|
@topic_flag_types = Enum.new
|
|
|
|
@notify_types = Enum.new
|
|
|
|
@auto_action_types = Enum.new
|
2024-07-17 19:10:22 -05:00
|
|
|
@additional_message_types = Enum.new
|
|
|
|
@without_additional_message_types = Enum.new
|
2024-05-22 21:19:07 -05:00
|
|
|
@names = Enum.new
|
2017-10-17 12:31:45 -05:00
|
|
|
end
|
|
|
|
|
2024-05-22 21:19:07 -05:00
|
|
|
def add(
|
|
|
|
id,
|
|
|
|
name_key,
|
|
|
|
topic_type: nil,
|
|
|
|
notify_type: nil,
|
|
|
|
auto_action_type: nil,
|
2024-07-17 19:10:22 -05:00
|
|
|
require_message: nil,
|
2024-05-22 21:19:07 -05:00
|
|
|
name: nil
|
|
|
|
)
|
|
|
|
@all_flag_types[name_key] = id
|
|
|
|
@topic_flag_types[name_key] = id if !!topic_type
|
|
|
|
@notify_types[name_key] = id if !!notify_type
|
|
|
|
@auto_action_types[name_key] = id if !!auto_action_type
|
|
|
|
@names[id] = name if name
|
2019-01-03 11:03:01 -06:00
|
|
|
|
2024-07-17 19:10:22 -05:00
|
|
|
if !!require_message
|
|
|
|
@additional_message_types[name_key] = id
|
2017-10-17 12:31:45 -05:00
|
|
|
else
|
2024-07-17 19:10:22 -05:00
|
|
|
@without_additional_message_types[name_key] = id
|
2017-10-17 12:31:45 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def is_flag?(key)
|
|
|
|
@all_flag_types.valid?(key)
|
|
|
|
end
|
|
|
|
|
|
|
|
def flag_types
|
|
|
|
@all_flag_types
|
|
|
|
end
|
|
|
|
end
|