Class: ArticleRevision::Approval
- Inherits:
-
Object
- Object
- ArticleRevision::Approval
- Defined in:
- app/services/article_revision/approval.rb
Overview
Applies one reviewed content proposal to its existing Article identity.
Defined Under Namespace
Classes: ApprovalError, Changes, Result
Constant Summary collapse
- IDENTITY_FIELDS =
%w[id slug state published_at precursor_id successor_article_id].freeze
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(revision:, reviewer:, review_notes:) ⇒ Approval
constructor
A new instance of Approval.
Constructor Details
#initialize(revision:, reviewer:, review_notes:) ⇒ Approval
Returns a new instance of Approval.
23 24 25 26 27 |
# File 'app/services/article_revision/approval.rb', line 23 def initialize(revision:, reviewer:, review_notes:) @revision = revision @reviewer = reviewer @review_notes = review_notes end |
Class Method Details
.call(revision:, reviewer:, review_notes: nil) ⇒ Object
19 20 21 |
# File 'app/services/article_revision/approval.rb', line 19 def self.call(revision:, reviewer:, review_notes: nil) new(revision:, reviewer:, review_notes:).call end |
Instance Method Details
#call ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'app/services/article_revision/approval.rb', line 29 def call apply_revision Result.new(revision:, errors: []) rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotDestroyed, StateMachines::InvalidTransition, ApprovalError => e errors = e.respond_to?(:record) ? e.record.errors. : [e.] Result.new(revision:, errors: errors) end |