lib/nanoc/base/entities/identifiable_collection.rb in nanoc-4.6.2 vs lib/nanoc/base/entities/identifiable_collection.rb in nanoc-4.6.3
- old
+ new
@@ -10,11 +10,11 @@
def_delegator :@objects, :size
contract C::Or[Hash, C::Named['Nanoc::Int::Configuration']], C::IterOf[C::RespondTo[:identifier]] => C::Any
def initialize(config, objects = [])
@config = config
- @objects = objects
+ @objects = Hamster::Vector.new(objects)
end
def self.from(enum, config)
new(config, enum)
end
@@ -41,19 +41,19 @@
end
end
contract C::None => C::ArrayOf[C::RespondTo[:identifier]]
def to_a
- @objects
+ @objects.to_a
end
contract C::None => C::Bool
def empty?
@objects.empty?
end
def add(obj)
- self.class.new(@config, @objects + [obj])
+ self.class.new(@config, @objects.add(obj))
end
def reject(&block)
self.class.new(@config, @objects.reject(&block))
end