Class: Pulitzer::UpdatePostTypeContentElements
- Inherits:
-
Object
- Object
- Pulitzer::UpdatePostTypeContentElements
- Defined in:
- app/interactions/pulitzer/update_post_type_content_elements.rb
Instance Attribute Summary collapse
-
#old_label ⇒ Object
Returns the value of attribute old_label.
-
#post_type ⇒ Object
Returns the value of attribute post_type.
-
#ptcet ⇒ Object
Returns the value of attribute ptcet.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(ptcet, old_label = nil) ⇒ UpdatePostTypeContentElements
constructor
A new instance of UpdatePostTypeContentElements.
Constructor Details
#initialize(ptcet, old_label = nil) ⇒ UpdatePostTypeContentElements
Returns a new instance of UpdatePostTypeContentElements.
4 5 6 7 8 |
# File 'app/interactions/pulitzer/update_post_type_content_elements.rb', line 4 def initialize(ptcet, old_label=nil) self.post_type = ptcet.post_type self.ptcet = ptcet self.old_label = old_label || ptcet.label end |
Instance Attribute Details
#old_label ⇒ Object
Returns the value of attribute old_label.
2 3 4 |
# File 'app/interactions/pulitzer/update_post_type_content_elements.rb', line 2 def old_label @old_label end |
#post_type ⇒ Object
Returns the value of attribute post_type.
2 3 4 |
# File 'app/interactions/pulitzer/update_post_type_content_elements.rb', line 2 def post_type @post_type end |
#ptcet ⇒ Object
Returns the value of attribute ptcet.
2 3 4 |
# File 'app/interactions/pulitzer/update_post_type_content_elements.rb', line 2 def ptcet @ptcet end |
Instance Method Details
#call ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/interactions/pulitzer/update_post_type_content_elements.rb', line 10 def call post_type.posts.each do |post| begin preview_version = post.get_preview_version! 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 rescue Pulitzer::VersionAccessError # if there is no preview version, skip this one. end end post_type.partials.joins(free_form_section: :version).where(pulitzer_versions: {status: 0}).each do |partial| partial.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 |