Class: PageVariants::Unpublish
- Inherits:
-
BaseService
- Object
- BaseService
- PageVariants::Unpublish
- Defined in:
- app/services/postnhost/publishing/page_variants/unpublish.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(page_variant:) ⇒ Unpublish
constructor
A new instance of Unpublish.
Constructor Details
#initialize(page_variant:) ⇒ Unpublish
Returns a new instance of Unpublish.
4 5 6 |
# File 'app/services/postnhost/publishing/page_variants/unpublish.rb', line 4 def initialize(page_variant:) @page_variant = page_variant end |
Instance Method Details
#call ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/services/postnhost/publishing/page_variants/unpublish.rb', line 8 def call snapshot = page_variant.page_variant_snapshot return failure("Page variant snapshot was not found", status: :not_found) unless snapshot Revision.hold do page_variant.page.lock! page_variant.lock! snapshot.destroy! end success(true, status: :ok) rescue ActiveRecord::RecordInvalid => e failure(e.) end |