Class: Grape::Validations::AttributesIterator

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(validator, scope, params) ⇒ AttributesIterator

Returns a new instance of AttributesIterator.



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

def initialize(validator, scope, params)
  @scope = scope
  @attrs = validator.attrs
  @original_params = scope.params(params)
  @params = Array.wrap(@original_params)
end

Instance Attribute Details

#scopeObject (readonly)

Returns the value of attribute scope.



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

def scope
  @scope
end

Instance Method Details

#each(&block) ⇒ Object



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

def each(&block)
  do_each(@params, &block) # because we need recursion for nested arrays
end