Sha256: 3735bf3acff198f79165c7c579d9959e072c3295084b31ab205cff966c339555

Contents?: true

Size: 843 Bytes

Versions: 77

Compression:

Stored size: 843 Bytes

Contents

# frozen_string_literal: true

require_dependency "renalware/letters"

module Renalware
  module Letters
    class LetterPolicy < BasePolicy
      alias_attribute :letter, :record

      def author?
        write_privileges?
      end

      def update?
        false
      end

      def submit_for_review?
        false
      end

      def reject?
        false
      end

      def approve?
        false
      end

      def complete?
        false
      end

      def destroy?
        return false if user_is_read_only?
        return false if %i(approved completed).include?(letter_state)

        user_is_admin? ||
          user_is_super_admin? ||
          letter.author == user ||
          letter.created_by == user
      end

      private

      def letter_state
        record.state.downcase.to_sym
      end
    end
  end
end

Version data entries

77 entries across 77 versions & 1 rubygems

Version Path
renalware-core-2.0.104 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.103 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.102 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.101 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.100 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.99 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.98 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.97 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.96 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.95 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.94 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.93 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.92 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.91 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.90 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.89 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.88 app/policies/renalware/letters/letter_policy.rb