lib/origen/sub_blocks.rb in origen-0.53.0 vs lib/origen/sub_blocks.rb in origen-0.53.1
- old
+ new
@@ -272,9 +272,16 @@
end
def sub_block(name = nil, options = {})
name, options = nil, name if name.is_a?(Hash)
return sub_blocks unless name
+
+ if name.is_a?(Class)
+ return sub_blocks.select { |n, s| s.is_a?(name) }
+ elsif name.origen_sub_block?
+ return sub_block(name.class)
+ end
+
if i = options.delete(:instances)
# permit creating multiple instances of a particular sub_block class
# can pass array for base_address, which will be processed above
Origen.deprecate 'instances: option to sub_block is deprecated, use sub_block_groups instead'
group_name = name =~ /s$/ ? name : "#{name}s" # take care if name already with 's' is passed