Class: RestaurantCpt::Operations::SettingSeo

Inherits:
Trailblazer::Operation
  • Object
show all
Defined in:
app/concepts/restaurant_cpt/operations/settings_seo.rb

Instance Method Summary collapse

Instance Method Details

#update_attributes!(options) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/concepts/restaurant_cpt/operations/settings_seo.rb', line 8

def update_attributes!(options, *)
  model = options['model']
  model.translated_attribute_names.each do |attr|
    MyLocaleManager.available_locales.each do |locale|
      params = options['params']["#{attr}_#{locale}"]
      unless params.nil?
        if params[:settings][:selected_mode] == 'manual'
          deactivate_related_settings(model, "#{attr}_#{locale}")
          model.send("#{attr}_#{locale}=".to_sym, params[:settings][:manual][:value])
        else
          model.send("#{params[:settings][:selected_mode]}=".to_sym, true)
        end
      end
    end
  end
  result = model.save
  options['model'] = model

  result
end