class Type::Definition::Collection
Type::Definition::Collection
validate and cast enumerables. For a more interesting implementation, see the constrained implementation of Type::Definition::Collection::Constrained
Re-open Collection
to add constraint methods
Public Instance Methods
cast!(input, &block)
click to toggle source
Calls superclass method
Type::Definition#cast!
# File lib/type/definition/collection.rb, line 25 def cast!(input, &block) raise CastError.new(input, self) unless input.kind_of?(Enumerable) super end
constrain(constraint)
click to toggle source
@overload constrain(constraint)
@param constraint [Type::Definition]
@overload constrain(constraint)
@param constraint [Hash{Type::Defintion=>Type::Defintion}] a single-element hash whose key is the constraint for keys, and whose value is a constraint for values
@return [Type::Defintion::Collection::Constrained]
# File lib/type/definition/collection/constrained.rb, line 14 def constrain(constraint) Constrained.new(self, constraint) end
Also aliased as: of
constrained?()
click to toggle source
@return [False]
# File lib/type/definition/collection/constrained.rb, line 20 def constrained? false end
valid?(input, *args, &block)
click to toggle source
Calls superclass method
Type::Definition#valid?
# File lib/type/definition/collection.rb, line 20 def valid?(input, *args, &block) return false unless input.kind_of?(Enumerable) super end