Class: Pulitzer::UpdateContentElement

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

Instance Method Summary collapse

Constructor Details

#initialize(content_element, params) ⇒ UpdateContentElement

Returns a new instance of UpdateContentElement.



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

def initialize(content_element, params)
  @content_element, @params = content_element, params.dup
end

Instance Method Details

#callObject



7
8
9
10
11
12
13
14
# File 'app/interactions/pulitzer/update_content_element.rb', line 7

def call
  text_editor = Pulitzer.text_editor_toolbars.detect { |toolbar| toolbar[:name] == content_element.text_editor }
  if 'Kramdown' == text_editor[:kind]
    params[:markdown] = params[:body]
    params[:body] = Kramdown::Document.new(params[:body]).to_html
  end
  @content_element.update params
end