Sha256: c7d669e957a28ad5ebeabb19e3ba6bcfeafd3c391ee07570b270b236da389e30

Contents?: true

Size: 685 Bytes

Versions: 23

Compression:

Stored size: 685 Bytes

Contents

class Pulitzer::UpdatePostTypeContentElements
  attr_accessor :post_type, :ptcet, :old_label

  def initialize(ptcet, old_label=nil)
    self.post_type  = ptcet.post_type
    self.ptcet      = ptcet
    self.old_label  = old_label || ptcet.label
  end

  def call
    post_type.posts.each do |post|
      post.preview_version.content_elements.where(label: old_label).each do |content_element|
        content_element.update(label: ptcet.label,
          height: ptcet.height,
          width: ptcet.width,
          text_editor: ptcet.text_editor,
          content_element_type: ptcet.content_element_type,
          post_type_content_element_type: ptcet)
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
pulitzer-0.1.5 app/interactions/pulitzer/update_post_type_content_elements.rb
pulitzer-0.1.4 app/interactions/pulitzer/update_post_type_content_elements.rb
pulitzer-0.1.3 app/interactions/pulitzer/update_post_type_content_elements.rb