Class: Articles::Publish

Inherits:
BaseService
  • Object
show all
Defined in:
app/services/postnhost/publishing/articles/publish.rb

Instance Method Summary collapse

Constructor Details

#initialize(article:) ⇒ Publish

Returns a new instance of Publish.



4
5
6
# File 'app/services/postnhost/publishing/articles/publish.rb', line 4

def initialize(article:)
  @article = article
end

Instance Method Details

#callObject



8
9
10
11
12
13
14
15
16
17
18
# File 'app/services/postnhost/publishing/articles/publish.rb', line 8

def call
  snapshot = Revision.hold do
    article.lock!
    Articles::SnapshotWriter.new(article:).call
  end
  success(snapshot, status: :ok)
rescue Error => e
  failure(e.messages)
rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotUnique => e
  failure(e.message)
end