Sha256: 5a0c52f1082e4b0739c9ac3ae0adae8dd8039167992ca923fc619c10f41f26a1

Contents?: true

Size: 642 Bytes

Versions: 1

Compression:

Stored size: 642 Bytes

Contents

# frozen_string_literal: true

module Doorkeeper
  module Orm
    module Concerns
      module Mongoid
        module Ownership
          extend ActiveSupport::Concern

          included do
            belongs_to_options = { polymorphic: true }

            if ::Mongoid::VERSION[0].to_i >= 6
              belongs_to_options[:optional] = true
            end

            belongs_to :owner, belongs_to_options
            validates :owner, presence: true, if: :validate_owner?
          end

          def validate_owner?
            Doorkeeper.configuration.confirm_application_owner?
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
doorkeeper-mongodb-5.0.0 lib/doorkeeper/orm/concerns/mongoid/ownership.rb