Class: Grape::Validations::AttributesIterator

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

Instance Method Summary collapse

Constructor Details

#initialize(validator, scope, params) ⇒ AttributesIterator

Returns a new instance of AttributesIterator



6
7
8
9
10
# File 'lib/grape/validations/attributes_iterator.rb', line 6

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

Instance Method Details

#eachObject



12
13
14
15
16
17
18
# File 'lib/grape/validations/attributes_iterator.rb', line 12

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