Class: Pulitzer::UpdateVersionStatus
- Inherits:
-
Object
- Object
- Pulitzer::UpdateVersionStatus
- Defined in:
- app/interactions/pulitzer/update_version_status.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(version, status) ⇒ UpdateVersionStatus
constructor
A new instance of UpdateVersionStatus.
- #make_version_abandoned ⇒ Object
- #make_version_active ⇒ Object
Constructor Details
#initialize(version, status) ⇒ UpdateVersionStatus
Returns a new instance of UpdateVersionStatus.
2 3 4 5 6 7 |
# File 'app/interactions/pulitzer/update_version_status.rb', line 2 def initialize(version, status) @transitional_version = version @status = status @status_change_method = 'make_version_' + @status.to_s @post = version.post end |
Instance Method Details
#call ⇒ Object
9 10 11 |
# File 'app/interactions/pulitzer/update_version_status.rb', line 9 def call send @status_change_method end |
#make_version_abandoned ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/interactions/pulitzer/update_version_status.rb', line 29 def make_version_abandoned @active_version = @transitional_version.post.active_version @transitional_version.update(status: :abandoned) if @active_version == @transitional_version @transitional_version.post.preview_version else @processing_version = @post.create_processing_version Pulitzer::CloneVersionJob.perform_later(@active_version) @processing_version end end |
#make_version_active ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/interactions/pulitzer/update_version_status.rb', line 13 def make_version_active @new_active_version = @transitional_version @old_active_version = @new_active_version.post.active_version begin @new_active_version.update!(status: :active) rescue ActiveRecord::RecordInvalid => invalid Rails.logger.error(invalid.record.errors..to_s) end @new_active_version..each &:touch @old_active_version.update(status: :archived) if @old_active_version @processing_version = @post.create_processing_version Pulitzer::CloneVersionJob.perform_later(@new_active_version) @post.reload @processing_version.reload end |