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



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

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



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

def scope
  @scope
end

Instance Method Details

#each(&block) ⇒ Object



15
16
17
# File 'lib/grape/validations/attributes_iterator.rb', line 15

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