Sha256: 4b67d3732405685a296f25cb4a344178aeb92f456227f0d4ef855b6117f8a1ae

Contents?: true

Size: 882 Bytes

Versions: 9

Compression:

Stored size: 882 Bytes

Contents

# frozen_string_literal: true

class Serega
  module SeregaPlugins
    module ExplicitManyOption
      #
      # Validator for attribute :many option
      #
      class CheckOptMany
        class << self
          #
          # Checks attribute :many option must be provided with relations
          #
          # @param opts [Hash] Attribute options
          #
          # @raise [SeregaError] Attribute validation error
          #
          # @return [void]
          #
          def call(opts)
            serializer = opts[:serializer]
            return unless serializer

            many_option_exists = opts.key?(:many)
            return if many_option_exists

            raise SeregaError,
              "Attribute option :many [Boolean] must be provided" \
              " for attributes with :serializer option"
          end
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
serega-0.21.0 lib/serega/plugins/explicit_many_option/validations/check_opt_many.rb
serega-0.20.1 lib/serega/plugins/explicit_many_option/validations/check_opt_many.rb
serega-0.20.0 lib/serega/plugins/explicit_many_option/validations/check_opt_many.rb
serega-0.19.0 lib/serega/plugins/explicit_many_option/validations/check_opt_many.rb
serega-0.18.0 lib/serega/plugins/explicit_many_option/validations/check_opt_many.rb
serega-0.17.0 lib/serega/plugins/explicit_many_option/validations/check_opt_many.rb
serega-0.16.0 lib/serega/plugins/explicit_many_option/validations/check_opt_many.rb
serega-0.15.0 lib/serega/plugins/explicit_many_option/validations/check_opt_many.rb
serega-0.14.0 lib/serega/plugins/explicit_many_option/validations/check_opt_many.rb