Skip to content

A platform for community discussion. Free, open, simple.

DEV: Compatibility with TruffleRuby (#16864)

Gerhard Schlager0af05c2682fe
diff --git a/app/models/post_action_type.rb b/app/models/post_action_type.rb
index c73e171a1fb..a209a79b6b0 100644
--- a/app/models/post_action_type.rb
+++ b/app/models/post_action_type.rb
@@ -12,51 +12,14 @@ class PostActionType < ActiveRecord::Base
end
class << self
-
- def flag_settings
- unless @flag_settings
- @flag_settings = FlagSettings.new
- @flag_settings.add(
- 3,
- :off_topic,
- notify_type: true,
- auto_action_type: true,
- )
- @flag_settings.add(
- 4,
- :inappropriate,
- topic_type: true,
- notify_type: true,
- auto_action_type: true,
- )
- @flag_settings.add(
- 8,
- :spam,
- topic_type: true,
- notify_type: true,
- auto_action_type: true,
- )
- @flag_settings.add(
- 6,
- :notify_user,
- topic_type: false,
- notify_type: false,
- custom_type: true
- )
- @flag_settings.add(
- 7,
- :notify_moderators,
- topic_type: true,
- notify_type: true,
- custom_type: true
- )
- end
-
- @flag_settings
- end
+ attr_reader :flag_settings
def replace_flag_settings(settings)
- @flag_settings = settings
+ if settings
+ @flag_settings = settings
+ else
+ initialize_flag_settings
+ end
@types = nil
end
@@ -117,7 +80,49 @@ class PostActionType < ActiveRecord::Base
def is_flag?(sym)
flag_types.valid?(sym)
end
+
+ private
+
+ def initialize_flag_settings
+ @flag_settings = FlagSettings.new
+ @flag_settings.add(
+ 3,
+ :off_topic,
+ notify_type: true,
+ auto_action_type: true,
+ )
+ @flag_settings.add(
+ 4,
+ :inappropriate,
+ topic_type: true,
+ notify_type: true,
+ auto_action_type: true,
+ )
+ @flag_settings.add(
+ 8,
+ :spam,
+ topic_type: true,
+ notify_type: true,
+ auto_action_type: true,
+ )
+ @flag_settings.add(
+ 6,
+ :notify_user,
+ topic_type: false,
+ notify_type: false,
+ custom_type: true
+ )
+ @flag_settings.add(
+ 7,
+ :notify_moderators,
+ topic_type: true,
+ notify_type: true,
+ custom_type: true
+ )
+ end
end
+
+ initialize_flag_settings
end
# == Schema Information
diff --git a/lib/flag_settings.rb b/lib/flag_settings.rb
index 7a6b83d73a1..da86d2c1b43 100644
--- a/lib/flag_settings.rb
+++ b/lib/flag_settings.rb
@@ -20,8 +20,6 @@ class FlagSettings
end
def add(id, name, topic_type: nil, notify_type: nil, auto_action_type: nil, custom_type: nil)
- details ||= {}
-
@all_flag_types[name] = id
@topic_flag_types[name] = id if !!topic_type
@notify_types[name] = id if !!notify_type