Sha256: 7fb0eb3031eab94293734ac96f3453923c069b0cf39e370c5393e3130d15b3fb

Contents?: true

Size: 956 Bytes

Versions: 8

Compression:

Stored size: 956 Bytes

Contents

# frozen_string_literal: true

class Serega
  module SeregaValidations
    module Attribute
      class CheckOptConst
        #
        # Checks attribute :const option
        #
        # @param opts [Hash] Attribute options
        #
        # @raise [SeregaError] Attribute validation error
        #
        # @return [void]
        #
        class << self
          def call(opts, block = nil)
            return unless opts.key?(:const)

            check_usage_with_other_params(opts, block)
          end

          private

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
serega-0.6.1 lib/serega/validations/attribute/check_opt_const.rb
serega-0.6.0 lib/serega/validations/attribute/check_opt_const.rb
serega-0.5.2 lib/serega/validations/attribute/check_opt_const.rb
serega-0.5.1 lib/serega/validations/attribute/check_opt_const.rb
serega-0.5.0 lib/serega/validations/attribute/check_opt_const.rb
serega-0.4.0 lib/serega/validations/attribute/check_opt_const.rb
serega-0.3.0 lib/serega/validations/attribute/check_opt_const.rb
serega-0.2.0 lib/serega/validations/attribute/check_opt_const.rb