2019-05-02 17:17:27 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-10-17 12:31:45 -05:00
|
|
|
class FlagSettings
|
|
|
|
attr_reader(
|
|
|
|
:without_custom_types,
|
|
|
|
:notify_types,
|
|
|
|
:topic_flag_types,
|
|
|
|
:auto_action_types,
|
2023-01-09 06:10:19 -06:00
|
|
|
:custom_types,
|
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
|
|
|
|
@custom_types = Enum.new
|
|
|
|
@without_custom_types = Enum.new
|
|
|
|
end
|
|
|
|
|
2019-01-03 11:03:01 -06:00
|
|
|
def add(id, name, topic_type: nil, notify_type: nil, auto_action_type: nil, custom_type: nil)
|
2017-10-17 12:31:45 -05:00
|
|
|
@all_flag_types[name] = id
|
2019-01-03 11:03:01 -06:00
|
|
|
@topic_flag_types[name] = id if !!topic_type
|
|
|
|
@notify_types[name] = id if !!notify_type
|
|
|
|
@auto_action_types[name] = id if !!auto_action_type
|
|
|
|
|
|
|
|
if !!custom_type
|
2017-10-17 12:31:45 -05:00
|
|
|
@custom_types[name] = id
|
|
|
|
else
|
|
|
|
@without_custom_types[name] = id
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def is_flag?(key)
|
|
|
|
@all_flag_types.valid?(key)
|
|
|
|
end
|
|
|
|
|
|
|
|
def flag_types
|
|
|
|
@all_flag_types
|
|
|
|
end
|
|
|
|
end
|