Method: Grape::Validations::Types::CustomTypeCollectionCoercer#initialize

Defined in:
lib/grape/validations/types/custom_type_collection_coercer.rb

#initialize(type, set = false) ⇒ CustomTypeCollectionCoercer

A new coercer for collections of the given type.

Parameters:

  • type (Class, #parse)

    type to which items in the array should be coerced. Must implement a parse method which accepts a string, and for the purposes of type-checking it may either be a class, or it may implement a coerced?, parsed? or call method (in that order of precedence) which accepts a single argument and returns true if the given array item has been coerced correctly.

  • set (Boolean) (defaults to: false)

    when true, a Set will be returned by #call instead of an Array and duplicate items will be discarded.



32
33
34
35
# File 'lib/grape/validations/types/custom_type_collection_coercer.rb', line 32

def initialize(type, set = false)
  super(type)
  @set = set
end