lib/origen/componentable.rb in origen-0.33.0 vs lib/origen/componentable.rb in origen-0.33.1
- old
+ new
@@ -382,15 +382,11 @@
instances = {}
options[:instances].times do |i|
opts = {}
# merge the given options with any that are overriden with the block.
- if block_given?
- collector = Origen::Utility::Collector.new
- yield collector
- options.merge!(collector.store)
- end
+ options = Origen::Utility.collector(hash: options, merge_method: :keep_hash, &block).to_h
# go through the options one by one now and make sure that each element is either an array to be split
# by the instances, or is a single object. If not one of these two, complain.
options.each do |key, val|
if val.is_a?(Array)
@@ -415,15 +411,11 @@
# set the instance's name and add it and its options to the list to be added
instances["#{name}#{i}".to_sym] = opts
end
instances
else
- if block_given?
- collector = Origen::Utility::Collector.new
- yield collector
- options.merge!(collector.store)
- end
+ options = Origen::Utility.collector(hash: options, merge_method: :keep_hash, &block).to_h
{ name => options }
end
end
# Adds a new item to the componentable container.
@@ -441,14 +433,10 @@
options = {
name: name,
parent: parent
}.merge(options)
- if block_given?
- collector = Origen::Utility::Collector.new
- yield collector
- options.merge!(collector.store)
- end
+ options = Origen::Utility.collector(hash: options, merge_method: :keep_hash, &block).to_h
# Instantiate the class. This will place the object in the @_componentable_container at the indicated name
_instantiate_class(name, options)
# Create an accessor for the new item, if indicated to do so.