Sha256: b6ac0b11394a1b82f6384067bfeb9bc5ffaa809d10418ef25fb48fdc861e95e7

Contents?: true

Size: 1.02 KB

Versions: 7

Compression:

Stored size: 1.02 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 :method" if opts.key?(:method)
            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

7 entries across 7 versions & 1 rubygems

Version Path
serega-0.21.0 lib/serega/validations/attribute/check_opt_const.rb
serega-0.20.1 lib/serega/validations/attribute/check_opt_const.rb
serega-0.20.0 lib/serega/validations/attribute/check_opt_const.rb
serega-0.19.0 lib/serega/validations/attribute/check_opt_const.rb
serega-0.18.0 lib/serega/validations/attribute/check_opt_const.rb
serega-0.17.0 lib/serega/validations/attribute/check_opt_const.rb
serega-0.16.0 lib/serega/validations/attribute/check_opt_const.rb