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