Sha256: e1192bbc73ae4ecc5862ee59094ffc52f10dec5f4865fe5fcd83d0ab648ccd68

Contents?: true

Size: 519 Bytes

Versions: 5

Compression:

Stored size: 519 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.content_elements.where(label: old_label).each do |ce|
        ce.update(label: ptcet.label, content_element_type: ptcet.content_element_type, post_type_content_element_type: ptcet)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pulitzer-0.1.1 app/interactions/pulitzer/update_post_type_content_elements.rb
pulitzer-0.1.0 app/interactions/pulitzer/update_post_type_content_elements.rb
pulitzer-0.0.5 app/interactions/pulitzer/update_post_type_content_elements.rb
pulitzer-0.0.4 app/interactions/pulitzer/update_post_type_content_elements.rb
pulitzer-0.0.3 app/interactions/pulitzer/update_post_type_content_elements.rb