Class: Pulitzer::ContentElementsController::Update

Inherits:
Object
  • Object
show all
Defined in:
app/interactions/pulitzer/content_elements_controller/update.rb

Instance Method Summary collapse

Constructor Details

#initialize(content_element, params) ⇒ Update

Returns a new instance of Update.



3
4
5
# File 'app/interactions/pulitzer/content_elements_controller/update.rb', line 3

def initialize(content_element, params)
  @content_element, @params = content_element, params.to_h.to_hash.symbolize_keys
end

Instance Method Details

#callObject



7
8
9
10
# File 'app/interactions/pulitzer/content_elements_controller/update.rb', line 7

def call
  prune_params
  @content_element.update @params
end

#prune_paramsObject



12
13
14
15
16
17
18
19
20
# File 'app/interactions/pulitzer/content_elements_controller/update.rb', line 12

def prune_params
  clickable_kind = @params.delete :clickable_kind
  custom_option_list = GlobalID::Locator.locate(clickable_kind)
  if custom_option_list.present?
    @params[:body] = nil
  else
    @params[:custom_option_id] = nil
  end
end