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

Inherits:
Object
  • Object
show all
Defined in:
lib/contracts-ruby2/lib/contracts/builtin_contracts.rb,
lib/contracts-ruby3/lib/contracts/builtin_contracts.rb

Instance Method Summary collapse

Constructor Details

#initialize(collection_class, &before_new) ⇒ Factory

Returns a new instance of Factory.



295
296
297
298
# File 'lib/contracts-ruby2/lib/contracts/builtin_contracts.rb', line 295

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

Instance Method Details

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



300
301
302
303
# File 'lib/contracts-ruby2/lib/contracts/builtin_contracts.rb', line 300

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