Module: Grape::DSL::Validations::ClassMethods

Defined in:
lib/grape/dsl/validations.rb

Instance Method Summary collapse

Instance Method Details

#document_attribute(names, opts) ⇒ Object


21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/grape/dsl/validations.rb', line 21

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

#params(&block) ⇒ Object


17
18
19
# File 'lib/grape/dsl/validations.rb', line 17

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

#reset_validations!Object


11
12
13
14
15
# File 'lib/grape/dsl/validations.rb', line 11

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