Class: Decidim::SpamSignal::Config

Inherits:
ApplicationRecord
  • Object
show all
Defined in:
app/models/decidim/spam_signal/config.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.get_config(organization) ⇒ Object



10
11
12
13
14
15
# File 'app/models/decidim/spam_signal/config.rb', line 10

def self.get_config(organization)
  Config.find_or_create_by!(organization: organization) do |conf|
    conf.comment_settings = {}
    conf.profile_settings = {}
  end
end

Instance Method Details

#commentsObject



17
18
19
# File 'app/models/decidim/spam_signal/config.rb', line 17

def comments
  @comment_repo ||= SpamConfigRepo.new("comments", self.comment_settings)
end

#profilesObject



21
22
23
# File 'app/models/decidim/spam_signal/config.rb', line 21

def profiles
  @profile_repo ||= SpamConfigRepo.new("profiles", self.profile_settings)
end

#save_settingsObject



25
26
27
28
29
# File 'app/models/decidim/spam_signal/config.rb', line 25

def save_settings
  comment_settings_will_change!
  profile_settings_will_change!
  save!
end