Class: RestaurantTagCpt::Operations::Create

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

Instance Method Summary collapse

Instance Method Details

#find_model!(options) ⇒ Object



12
13
14
# File 'app/concepts/restaurant_tag_cpt/operations/create.rb', line 12

def find_model!(options, *)
  options['model'] = ::RestaurantTagCpt::ModelDecorator.new
end

#map_attributes!(options) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'app/concepts/restaurant_tag_cpt/operations/create.rb', line 16

def map_attributes!(options, *)
  MyLocaleManager.available_locales.each do |locale|
    tag_value = options[::OpCons::CONTRACT_DEFAULT].send("tag_#{locale}").to_s.strip
    title = if tag_value.blank?
              nil
            else
              "#{options[::OpCons::CONTRACT_DEFAULT].category}:#{tag_value}"
            end
    options[::OpCons::MODEL].send(:"title_#{locale}=", title)
  end
end