Sha256: 5e9eeabeb52838430dd19f6a981855bc99b785a882d710dbd9d2fc2df5b69392

Contents?: true

Size: 874 Bytes

Versions: 19

Compression:

Stored size: 874 Bytes

Contents

require_dependency "renalware/letters/letter"

module Renalware
  module Letters
    class Letter::PendingReview < Letter
      def self.policy_class
        PendingReviewLetterPolicy
      end

      def revise(params)
        params = LetterParamsProcessor.new(patient).call(params)
        self.attributes = params
      end

      def reject(by:)
        becomes!(Draft).tap { |letter| letter.by = by }
      end

      def sign(by:)
        build_signature(user: by, signed_at: Time.current)
        self.by = by
        self
      end

      def generate_archive(by:, presenter: default_presenter)
        becomes!(Approved).tap do |letter|
          letter.by = by
          letter.build_archive(by: by, content: presenter.content)
        end
      end

      private

      def default_presenter
        LetterPresenterFactory.new(self)
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.rc11 app/models/renalware/letters/letter/pending_review.rb
renalware-core-2.0.0.pre.rc10 app/models/renalware/letters/letter/pending_review.rb
renalware-core-2.0.0.pre.rc9 app/models/renalware/letters/letter/pending_review.rb
renalware-core-2.0.0.pre.rc8 app/models/renalware/letters/letter/pending_review.rb
renalware-core-2.0.0.pre.rc7 app/models/renalware/letters/letter/pending_review.rb
renalware-core-2.0.0.pre.rc6 app/models/renalware/letters/letter/pending_review.rb
renalware-core-2.0.0.pre.rc5 app/models/renalware/letters/letter/pending_review.rb
renalware-core-2.0.0.pre.rc4 app/models/renalware/letters/letter/pending_review.rb
renalware-core-2.0.0.pre.rc3 app/models/renalware/letters/letter/pending_review.rb
renalware-core-2.0.0.pre.rc1 app/models/renalware/letters/letter/pending_review.rb
renalware-core-2.0.0.pre.beta12 app/models/renalware/letters/letter/pending_review.rb
renalware-core-2.0.0.pre.beta11 app/models/renalware/letters/letter/pending_review.rb
renalware-core-2.0.0.pre.beta10 app/models/renalware/letters/letter/pending_review.rb
renalware-core-2.0.0.pre.beta9 app/models/renalware/letters/letter/pending_review.rb
renalware-core-2.0.0.pre.beta8 app/models/renalware/letters/letter/pending_review.rb
renalware-core-2.0.0.pre.beta7 app/models/renalware/letters/letter/pending_review.rb
renalware-core-2.0.0.pre.beta6 app/models/renalware/letters/letter/pending_review.rb
renalware-core-2.0.0.pre.beta5 app/models/renalware/letters/letter/pending_review.rb
renalware-core-2.0.0.pre.beta4 app/models/renalware/letters/letter/pending_review.rb