Sha256: 25551000fd86333b6ff5a37da4a1e0a522c0ae38de1c4dd680a356049f68c48a

Contents?: true

Size: 1.17 KB

Versions: 7

Compression:

Stored size: 1.17 KB

Contents

module Approval
  module Mixins
    module User
      extend ActiveSupport::Concern

      included do
        has_many :approval_requests, class_name: :"Approval::Request", foreign_key: :request_user_id
        has_many :approval_comments, class_name: :"Approval::Comment", foreign_key: :user_id
      end

      def request_for_create(records, reason:)
        Approval::RequestForm::Create.new(user: self, reason: reason, records: records)
      end

      def request_for_update(records, reason:)
        Approval::RequestForm::Update.new(user: self, reason: reason, records: records)
      end

      def request_for_destroy(records, reason:)
        Approval::RequestForm::Destroy.new(user: self, reason: reason, records: records)
      end

      def cancel_request(request, reason:)
        Approval::RespondForm::Cancel.new(user: self, reason: reason, request: request)
      end

      def approve_request(request, reason:)
        Approval::RespondForm::Approve.new(user: self, reason: reason, request: request)
      end

      def reject_request(request, reason:)
        Approval::RespondForm::Reject.new(user: self, reason: reason, request: request)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
approval-0.3.5 lib/approval/mixins/user.rb
approval-0.3.4 lib/approval/mixins/user.rb
approval-0.3.3 lib/approval/mixins/user.rb
approval-0.3.2 lib/approval/mixins/user.rb
approval-0.2.3 lib/approval/mixins/user.rb
approval-0.2.2 lib/approval/mixins/user.rb
approval-0.2.0 lib/approval/mixins/user.rb