Sha256: 3927f2be03c3141904a89ef793eff66fe14fdf8b2bc3d0f4fe59881d53f80b48

Contents?: true

Size: 1.01 KB

Versions: 13

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

class Serega
  module SeregaValidations
    module Attribute
      #
      # Attribute `:const` option validator
      #
      class CheckOptConst
        class << self
          #
          # Checks attribute :const option
          #
          # @param opts [Hash] Attribute options
          #
          # @raise [SeregaError] Attribute validation error
          #
          # @return [void]
          #
          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

13 entries across 13 versions & 1 rubygems

Version Path
serega-0.15.0 lib/serega/validations/attribute/check_opt_const.rb
serega-0.14.0 lib/serega/validations/attribute/check_opt_const.rb
serega-0.12.0 lib/serega/validations/attribute/check_opt_const.rb
serega-0.11.2 lib/serega/validations/attribute/check_opt_const.rb
serega-0.11.1 lib/serega/validations/attribute/check_opt_const.rb
serega-0.11.0 lib/serega/validations/attribute/check_opt_const.rb
serega-0.10.0 lib/serega/validations/attribute/check_opt_const.rb
serega-0.9.0 lib/serega/validations/attribute/check_opt_const.rb
serega-0.8.3 lib/serega/validations/attribute/check_opt_const.rb
serega-0.8.2 lib/serega/validations/attribute/check_opt_const.rb
serega-0.8.1 lib/serega/validations/attribute/check_opt_const.rb
serega-0.8.0 lib/serega/validations/attribute/check_opt_const.rb
serega-0.7.0 lib/serega/validations/attribute/check_opt_const.rb