Class: Grape::Validations::Validator::AttributesIterator

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/grape/validations.rb

Instance Method Summary collapse

Constructor Details

#initialize(validator, scope, params) ⇒ AttributesIterator

Returns a new instance of AttributesIterator.



27
28
29
30
31
# File 'lib/grape/validations.rb', line 27

def initialize(validator, scope, params)
  @attrs = validator.attrs
  @params = scope.params(params)
  @params = (@params.is_a?(Array) ? @params : [@params])
end

Instance Method Details

#eachObject



33
34
35
36
37
38
39
# File 'lib/grape/validations.rb', line 33

def each
  @params.each do |resource_params|
    @attrs.each do |attr_name|
      yield resource_params, attr_name
    end
  end
end