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.1.1 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.1.0 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.167 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.166 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.165 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.164 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.163 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.162 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.161 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.160 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.159 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.158 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.157 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.156 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.155 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.153 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.152 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.151 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.149 app/policies/renalware/letters/letter_policy.rb
renalware-core-2.0.148 app/policies/renalware/letters/letter_policy.rb