Sha256: 14898d9e57e1fc3e7bf05e3125fffe8b4a5d193c320d2d42025e04f301918877

Contents?: true

Size: 999 Bytes

Versions: 4

Compression:

Stored size: 999 Bytes

Contents

require 'active_support/concern'

module Grape
  module DSL
    module Validations
      extend ActiveSupport::Concern

      include Grape::DSL::Configuration

      module ClassMethods
        def reset_validations!
          unset_namespace_stackable :declared_params
          unset_namespace_stackable :validations
          unset_namespace_stackable :params
        end

        def params(&block)
          Grape::Validations::ParamsScope.new(api: self, type: Hash, &block)
        end

        def document_attribute(names, opts)
          route_setting(:description, {}) unless route_setting(:description)

          route_setting(:description)[:params] ||= {}

          setting = route_setting(:description)[:params]
          Array(names).each do |name|
            setting[name[:full_name].to_s] ||= {}
            setting[name[:full_name].to_s].merge!(opts)

            namespace_stackable(:params, name[:full_name].to_s => opts)
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
grape-0.12.0 lib/grape/dsl/validations.rb
grape-0.11.0 lib/grape/dsl/validations.rb
grape-0.10.1 lib/grape/dsl/validations.rb
grape-0.10.0 lib/grape/dsl/validations.rb