Class: Contracts::Builtin::CollectionOf::Factory

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

Instance Method Summary collapse

Constructor Details

#initialize(collection_class, &before_new) ⇒ Factory

Returns a new instance of Factory.


314
315
316
317
# File 'lib/contracts/builtin_contracts.rb', line 314

def initialize(collection_class, &before_new)
  @collection_class = collection_class
  @before_new = before_new
end

Instance Method Details

#new(contract) ⇒ Object Also known as: []


319
320
321
322
# File 'lib/contracts/builtin_contracts.rb', line 319

def new(contract)
  @before_new&.call
  CollectionOf.new(@collection_class, contract)
end