aglushkov/serega

View on GitHub
lib/serega/plugins/preloads/validations/check_opt_preload.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
# frozen_string_literal: true

class Serega
  module SeregaPlugins
    module Preloads
      #
      # Validator for attribute :preload option
      #
      class CheckOptPreload
        class << self
          #
          # Checks :preload option
          #
          # @param opts [Hash] Attribute options
          #
          # @raise [SeregaError] validation error
          #
          # @return [void]
          def call(opts)
            return unless opts.key?(:preload)

            raise SeregaError, "Option :preload can not be used together with option :const" if opts.key?(:const)
          end
        end
      end
    end
  end
end