Module: Grape::Validations::ClassMethods

Included in:
API
Defined in:
lib/grape/validations.rb

Overview

This module is mixed into the API Class.

Instance Method Summary collapse

Instance Method Details

#document_attribute(names, opts) ⇒ Object


307
308
309
310
311
312
313
314
# File 'lib/grape/validations.rb', line 307

def document_attribute(names, opts)
  @last_description ||= {}
  @last_description[:params] ||= {}
  Array(names).each do |name|
    @last_description[:params][name[:full_name].to_s] ||= {}
    @last_description[:params][name[:full_name].to_s].merge!(opts)
  end
end

#params(&block) ⇒ Object


303
304
305
# File 'lib/grape/validations.rb', line 303

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

#reset_validations!Object


298
299
300
301
# File 'lib/grape/validations.rb', line 298

def reset_validations!
  settings.peek[:declared_params] = []
  settings.peek[:validations] = []
end