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.



294
295
296
297
# File 'lib/contracts/builtin_contracts.rb', line 294

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

Instance Method Details

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



299
300
301
302
# File 'lib/contracts/builtin_contracts.rb', line 299

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