debian-mirror-gitlab/app/services/application_settings/update_service.rb

23 lines
545 B
Ruby
Raw Normal View History

2017-08-17 22:00:37 +05:30
module ApplicationSettings
class UpdateService < ApplicationSettings::BaseService
def execute
2018-10-15 14:42:47 +05:30
update_terms(@params.delete(:terms))
2017-08-17 22:00:37 +05:30
@application_setting.update(@params)
end
2018-10-15 14:42:47 +05:30
private
def update_terms(terms)
return unless terms.present?
# Avoid creating a new terms record if the text is exactly the same.
terms = terms.strip
return if terms == @application_setting.terms
ApplicationSetting::Term.create(terms: terms)
@application_setting.reset_memoized_terms
end
2017-08-17 22:00:37 +05:30
end
end