Class: Contracts::Constraints::ArrayOf

Inherits:
Base
  • Object
show all
Defined in:
lib/contracts.rb

Instance Method Summary collapse

Methods inherited from Base

#to_h

Constructor Details

#initialize(item) ⇒ ArrayOf

Returns a new instance of ArrayOf.



252
# File 'lib/contracts.rb', line 252

def initialize(item) = @item = Constraints.coerce(item)

Instance Method Details

#descriptionObject



254
# File 'lib/contracts.rb', line 254

def description = "Array<#{@item.description}>"

#matches?(value) ⇒ Boolean

Returns:

  • (Boolean)


253
# File 'lib/contracts.rb', line 253

def matches?(value) = value.is_a?(Array) && value.all? { |v| @item.matches?(v) }