Class: Contracts::Builtin::CollectionOf::Factory
- Inherits:
-
Object
- Object
- Contracts::Builtin::CollectionOf::Factory
- Defined in:
- lib/contracts/builtin_contracts.rb
Instance Method Summary collapse
-
#initialize(collection_class, &before_new) ⇒ Factory
constructor
A new instance of Factory.
- #new(contract) ⇒ Object (also: #[])
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 |