Sha256: 831275b045e58408489c0e9eb381af3f6421454c217b41ec5db08dfaeb768be4

Contents?: true

Size: 738 Bytes

Versions: 11

Compression:

Stored size: 738 Bytes

Contents

require_dependency "renalware/letters"

module Renalware
  module Letters
    class ApproveLetter
      class << self
        alias_method :build, :new
      end

      def initialize(letter)
        @letter = letter
      end

      def call(by:)
        Letter.transaction do
          sign(by: by)
          archive_content(by: by)
          archive_recipients
        end
      end

      def sign(by:)
        # Needs to be saved before changing the STI type
        # (signature would be lost otherwise)
        @letter.sign(by: by).save!
      end

      def archive_content(by:)
        @letter.generate_archive(by: by).save!
      end

      def archive_recipients
        @letter.archive_recipients!
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.rc3 app/models/renalware/letters/approve_letter.rb
renalware-core-2.0.0.pre.rc1 app/models/renalware/letters/approve_letter.rb
renalware-core-2.0.0.pre.beta12 app/models/renalware/letters/approve_letter.rb
renalware-core-2.0.0.pre.beta11 app/models/renalware/letters/approve_letter.rb
renalware-core-2.0.0.pre.beta10 app/models/renalware/letters/approve_letter.rb
renalware-core-2.0.0.pre.beta9 app/models/renalware/letters/approve_letter.rb
renalware-core-2.0.0.pre.beta8 app/models/renalware/letters/approve_letter.rb
renalware-core-2.0.0.pre.beta7 app/models/renalware/letters/approve_letter.rb
renalware-core-2.0.0.pre.beta6 app/models/renalware/letters/approve_letter.rb
renalware-core-2.0.0.pre.beta5 app/models/renalware/letters/approve_letter.rb
renalware-core-2.0.0.pre.beta4 app/models/renalware/letters/approve_letter.rb