Class: Contracts::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.


266
267
268
269
# File 'lib/contracts/builtin_contracts.rb', line 266

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

Instance Method Details

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


271
272
273
274
# File 'lib/contracts/builtin_contracts.rb', line 271

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