docbrown/app/models/settings/mandatory.rb
praveen raghav ns 80c8e49a85
Use constants for controller allowed params (#14815)
* Constants for controller allowed params

* Apply suggestions from code review

Co-authored-by: Michael Kohl <me@citizen428.net>

Co-authored-by: Michael Kohl <me@citizen428.net>
2021-09-28 16:30:56 +02:00

29 lines
706 B
Ruby

module Settings
# We use this model to back the "Get Started" form of the config admin page.
class Mandatory
include ActiveModel::Naming
MAPPINGS = {
community_name: Settings::Community,
community_description: Settings::Community,
suggested_tags: Settings::General,
suggested_users: Settings::General
}.freeze
MAPPING_KEYS = MAPPINGS.keys
MAPPINGS.each do |setting, settings_model|
delegate setting, "#{setting}=", to: settings_model
end
def self.keys
MAPPING_KEYS
end
def self.missing
MAPPINGS.reject do |settings, settings_model|
settings_model.public_send(settings).present?
end.keys
end
end
end